Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "TimMackey"

GetSeatGridInput.cs

using Abp.Application.Services.Dto;

namespace ngTTM.TtmDataModel.Dtos
{
    public class GetSeatGridInput : EntityDto<int?>
    {
        public int RoomId { get; set; }

        public int ScheduleId { get; set; }

        public int StudentId { get; set; }

        public int DayOfYearToday { get; set; }
    }
}

SeatsAppService.cs:

        public async Task<TtmSeatGridDto> GetSeatGrid(GetSeatGridInput seatGridFilter)
        {
            string roomIdFilter = seatGridFilter.RoomId.ToString();

            TtmSeatGridDto ttmSeatGridDto = new TtmSeatGridDto();

            ttmSeatGridDto.seatList = await GetTtmSeatsDto(
                new GetAllSeatsInput()
                {
                    SeatTagFilter = null,
                    RoomIdFilter = roomIdFilter,
                    RoomRoomNameFilter = null,
                    MaxResultCount = 1000,
                });

            ttmSeatGridDto.seatListIndex = new int[ttmSeatGridDto.seatList[0].Count - 1];
            // 0 is the frozen column, so list must start with 1
            for (int ndx = 0; ndx < ttmSeatGridDto.seatList[0].Count - 1; ndx++)
            {
                ttmSeatGridDto.seatListIndex[ndx] = ndx + 1;
            }

            ttmSeatGridDto.seatCount = _seatRepository.Count(s => s.Room.Id.ToString() == roomIdFilter && s.SeatType != SeatType.None);
            Seat seatR = _seatRepository.FirstOrDefault(s => s.Room.Id.ToString() == roomIdFilter);
            Seat seatA = await _seatRepository.FirstOrDefaultAsync(s => s.Room.Id.ToString() == roomIdFilter);
            Room room = _roomRepository.FirstOrDefault(r => r.Id == seatR.RoomId);
            ttmSeatGridDto.SeatsPerRowView = Math.Min(room.SeatsPerRowView, room.SeatsPerRow);

            return ttmSeatGridDto;
        }

seatAssignmentAppService.cs:

using Abp.Application.Services.Dto;
using Abp.Authorization;
using Abp.Domain.Repositories;
using Abp.Linq.Extensions;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using ngTTM.Authorization;
using ngTTM.TtmDataModel.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading.Tasks;

namespace ngTTM.TtmDataModel
{
    //#############################################################################################
    [AbpAuthorize(AppPermissions.Pages_SeatAssignments)]
    public class SeatAssignmentsAppService : ngTTMAppServiceBase
    {
        //=========================================================================================
        #region Private Fields
        //-----------------------------------------------------------------------------------------
        private readonly IRepository<ClassRoster> _classRosterRepository;
        private readonly ClassRostersAppService _classRostersAppService;
        private readonly IRepository<Room, int> _roomRepository;
        private readonly IRepository<Schedule, int> _scheduleRepository;
        private readonly SeatsAppService _seatAppService;
        private readonly IRepository<SeatAssignment> _seatAssignmentRepository;
        private readonly IRepository<Seat, int> _seatRepository;
        private readonly IRepository<Student, int> _studentRepository;
        private readonly StudentsAppService _studentsAppService;
        private readonly IRepository<Term> _termRepository;

        private readonly string entityName;
        private readonly string initstatus;
        //-----------------------------------------------------------------------------------------
        #endregion Private Fields
        //=========================================================================================
        #region Public Constructors
        //-----------------------------------------------------------------------------------------
        public SeatAssignmentsAppService(
            IRepository<SeatAssignment> seatAssignmentRepository,
            IRepository<Schedule, int> scheduleRepository,
            IRepository<Student, int> studentRepository,
            IRepository<Seat, int> seatRepository,
            IRepository<ClassRoster> classRosterRepository,
            IRepository<Room, int> roomRepository,
            IRepository<Term> termRepository,

            ClassRostersAppService classRostersAppService,
            StudentsAppService studentsAppService,
            SeatsAppService seatAppService
           )
        {
            _seatAssignmentRepository = seatAssignmentRepository;
            _scheduleRepository = scheduleRepository;
            _studentRepository = studentRepository;
            _seatRepository = seatRepository;
            _classRosterRepository = classRosterRepository;
            _roomRepository = roomRepository;
            _termRepository = termRepository;

            _classRostersAppService = classRostersAppService;
            _seatAppService = seatAppService;
            _studentsAppService = studentsAppService;

            entityName = L("SeatAssignment");
            initstatus = L("Success");
        }
        //-----------------------------------------------------------------------------------------
        #endregion Public Constructors
        //=========================================================================================

        //-----------------------------------------------------------------------------------------
        public async Task<TtmSeatGridDto> GetSeatGrid(GetSeatGridInput seatGridFilter)
        {
            TtmSeatGridDto ttmSeatGridDto = await _seatAppService.GetSeatGrid(seatGridFilter);

            // get all Assigned Seats in the specified Section
            List<int> assignedSeats = await GetAssignedSeatsList(seatGridFilter.ScheduleId);

            int totalAbsent = 0;
            int totalNotRecorded = 0;
            int totalPresent = 0;
            int totalTardy = 0;

            foreach (List<TtmSeatsDto> seatRow in ttmSeatGridDto.seatList)
            {
                foreach (TtmSeatsDto seat in seatRow)
                {
                    if (assignedSeats.Contains(seat.seatId))
                    {
                        SeatAssignment seatassn = 
                            await _seatAssignmentRepository.FirstOrDefaultAsync(s => s.SeatId == seat.seatId);
                        int doyIndex = seatassn.Schedule.GetMeetingDayOfYearIndex(seatGridFilter.DayOfYearToday);
                        AttendanceStatus? todayStatus = null;
                        if (doyIndex > 0 && seatassn.AttendanceStatusCount >= doyIndex - 1)
                        {
                            todayStatus = seatassn.AttendanceStatuses[doyIndex];
                            switch (todayStatus)
                            {
                                case AttendanceStatus.Absent:
                                    totalAbsent++;
                                    break;
                                case AttendanceStatus.NotRecorded:
                                    totalNotRecorded++;
                                    break;
                                case AttendanceStatus.Present:
                                    totalPresent++;
                                    break;
                                case AttendanceStatus.Tardy:
                                    totalTardy++;
                                    break;
                            }
                        }
                        Student student = 
                            await _studentRepository.FirstOrDefaultAsync(s => s.Id == seatassn.StudentId);
                        seat.isAssigned = true;
                        seat.seatAssignmentId = seatassn.Id;
                        seat.studentId = student.Id;
                        seat.studentName = student.StudentName;
                        seat.seatPreference = student.SeatPreference;
                        seat.studentPhotoBase64 = 
                            await _studentsAppService.GetStudentPhotoById(student.StudentPhotoId);
                        seat.attendanceStatus = todayStatus;
                        seat.firstName = student.FirstName;
                        seat.lastName = student.LastName;
                        seat.daysAbsent = seatassn.StatusCount(AttendanceStatus.Absent);
                        seat.daysNotRecorded = seatassn.StatusCount(AttendanceStatus.NotRecorded);
                        seat.daysPresent = seatassn.StatusCount(AttendanceStatus.Present);
                        seat.daysTardy = seatassn.StatusCount(AttendanceStatus.Tardy);
                        seat.daysTotal = seatassn.AttendanceStatusCount;
                        seat.studentInteractions = seatassn.StudentInteractions;
                        seat.studentNotes = seatassn.StudentNotes;
                    }
                }
            }
            ttmSeatGridDto.classroomSeats = new TtmSeatsDto();
            ttmSeatGridDto.classroomSeats.daysAbsent = totalAbsent;
            ttmSeatGridDto.classroomSeats.daysNotRecorded = totalNotRecorded;
            ttmSeatGridDto.classroomSeats.daysPresent = totalPresent;
            ttmSeatGridDto.classroomSeats.daysTardy = totalTardy;
            ttmSeatGridDto.classroomSeats.daysTotal = totalAbsent + totalNotRecorded + totalPresent + totalTardy;

            ttmSeatGridDto.IsExistAttendanceRecordForToday =
                await IsExistAttendanceRecordForToday(seatGridFilter.ScheduleId,
                                                      seatGridFilter.DayOfYearToday);

            return ttmSeatGridDto;
        }
        //-----------------------------------------------------------------------------------------

TtmSeats.Dto.cs

namespace ngTTM.TtmDataModel.Dtos
{
    public class TtmSeatsDto
    {
        public int seatId { get; set; }

        public int studentId { get; set; }

        public int seatAssignmentId { get; set; }

        public int actualRow { get; set; }

        public int actualSeat{ get; set; }

        public int daysPresent { get; set; }

        public int daysAbsent { get; set; }

        public int daysTardy { get; set; }

        public int daysNotRecorded { get; set; }

        public int daysTotal { get; set; }

        public int studentInteractions { get; set; }

        public string studentNotes { get; set; }

        public string seatTag { get; set; }

        public string rowLetter { get; set; }

        public string firstName { get; set; }

        public string lastName { get; set; }

        public string studentName { get; set; }

        public string studentPhotoBase64 { get; set; }

        public SeatType seatType { get; set; }

        public SeatType seatPreference { get; set; }

        public AttendanceStatus? attendanceStatus { get; set; }
        
        public bool isAssigned { get; set; }

        public string dragOverClass { get; set; }

        public TtmSeatsDto() { }

        public TtmSeatsDto(
            int _seatId,
            int _studentId,
            int _actualRow,
            int _actualSeat,
            bool _isAssigned,
            string _rowLetter,
            string _seatTag,
            string _firstName,
            string _lastName,
            string _studentName,
            SeatType _seatType,
            SeatType _studentSeatpreference,
            AttendanceStatus? _attendanceStatus
        )
        {
            seatId = _seatId;
            actualRow = _actualRow;
            actualSeat = _actualSeat;
            rowLetter = _rowLetter;
            seatTag = _seatTag;
            firstName = _firstName;
            lastName = _lastName;
            studentName = _studentName;
            seatType = _seatType;
            isAssigned = _isAssigned;
            studentId = _studentId;
            seatPreference = _studentSeatpreference;
            attendanceStatus = _attendanceStatus;
            dragOverClass = "";
        }
    }
}

Generated code:

    /**
     * @param roomId (optional) 
     * @param scheduleId (optional) 
     * @param studentId (optional) 
     * @param dayOfYearToday (optional) 
     * @param id (optional) 
     * @return Success
     */
    getSeatGrid(roomId: number | null | undefined, scheduleId: number | null | undefined, studentId: number | null | undefined, dayOfYearToday: number | null | undefined, id: number | null | undefined): Observable<TtmSeatGridDto> {
        let url_ = this.baseUrl + "/api/services/app/SeatAssignments/GetSeatGrid?";
        if (roomId !== undefined)
            url_ += "RoomId=" + encodeURIComponent("" + roomId) + "&"; 
        if (scheduleId !== undefined)
            url_ += "ScheduleId=" + encodeURIComponent("" + scheduleId) + "&"; 
        if (studentId !== undefined)
            url_ += "StudentId=" + encodeURIComponent("" + studentId) + "&"; 
        if (dayOfYearToday !== undefined)
            url_ += "DayOfYearToday=" + encodeURIComponent("" + dayOfYearToday) + "&"; 
        if (id !== undefined)
            url_ += "Id=" + encodeURIComponent("" + id) + "&"; 
        url_ = url_.replace(/[?&]$/, "");

        let options_ : any = {
            observe: "response",
            responseType: "blob",
            headers: new HttpHeaders({
                "Accept": "application/json"
            })
        };

        return this.http.request("get", url_, options_).pipe(_observableMergeMap((response_ : any) => {
            return this.processGetSeatGrid(response_);
        })).pipe(_observableCatch((response_: any) => {
            if (response_ instanceof HttpResponseBase) {
                try {
                    return this.processGetSeatGrid(<any>response_);
                } catch (e) {
                    return <Observable<TtmSeatGridDto>><any>_observableThrow(e);
                }
            } else
                return <Observable<TtmSeatGridDto>><any>_observableThrow(response_);
        }));
    }

    protected processGetSeatGrid(response: HttpResponseBase): Observable<TtmSeatGridDto> {
        const status = response.status;
        const responseBlob = 
            response instanceof HttpResponse ? response.body : 
            (<any>response).error instanceof Blob ? (<any>response).error : undefined;

        let _headers: any = {}; if (response.headers) { for (let key of response.headers.keys()) { _headers[key] = response.headers.get(key); }};
        if (status === 200) {
            return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => {
            let result200: any = null;
            let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
            result200 = resultData200 ? TtmSeatGridDto.fromJS(resultData200) : new TtmSeatGridDto();
            return _observableOf(result200);
            }));
        } else if (status !== 200 && status !== 204) {
            return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => {
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
            }));
        }
        return _observableOf<TtmSeatGridDto>(<any>null);
    }

running npm run create-bundles in Web.Public folder is the solution. Thank you.

OK, don't use the above code. Your answer isn't very hepful. I am using the RAD tool to emit code which implements (somewhere, Apb?) soft delete. ISoftDelete does not exist in my app, ergo, I can't not do something that does not exist. Please show by example how to "not implement ISoftDelete" so that I can hard delete a record in a standard ANZ app.

I tried the above solution:

  1. adding the above code to my DbContext class.
  2. delete async as follows:
using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete))
{
    await _roomRepository.DeleteAsync(input.Id);   /* input.Id = 6 */
}

Yet the records are still soft deleted. How can I actually remove records from a table so that, for example, record id = 6 does not exist in the table?

Hard delete is a non-negotiable requirement for my application. Absent hard delete the database size would explode in a short time, and consist of 95% soft deleted records.

https://support.aspnetzero.com/QA/Questions?Sort=LastActivityDate-desc&CreatorUserId=2b107550-3b53-4613-bcab-6f4ef87d8eac

@ismcagdas - The solution you suggested solves the problem. Thank you.

Added the following to angular.json:

"glob": "**/*",
"input": "node_modules/@fortawesome",
"output": "/assets/@fortawesome"

and this to index.html:

<link rel="stylesheet" href="./assets/@fortawesome/fontawesome-pro/css/all.css">

@exInt - solution #3 file is src/index.html. You create the link yourself. My project type is Angular / Core.

@ismcagdas - Please refer to #5527 for installation and usage. The fonts have been working since August with versions 5.6.0 and 6.2.0.

Since my original post I have continued to try more potential solutions:

  1. modified src/index.html <link rel="stylesheet" href="../node_modules/@fortawesome/fontawesome-pro/css/all.css">
    1. removed rel="stylesheet",
    2. replaced href with src,
    3. replaced all.css with all.min.css
  2. added <base href="/"> before any <link .. >
  3. copied the entire @fortawesome folder to src/assets folder and changed index.html to <link rel="stylesheet" href="./assets/@fortawesome/fontawesome-pro/css/all.min.css">.

Item 3. does fix the issue, but isn't an ideal solution, since the 'assets' folder is reserved for modifed vendor-supplied components, and it's another setup setp. It will be OK as an interim solution during development. Still, it begs the question, what changed from 6.2.0 to 6.4.0 that would cause the error message and non-functionality?

Thank you for the clarification.

Showing 201 to 210 of 285 entries