Esempio n. 1
0
        public void AddRepairAndMaintenance(ServiceRequestModel <RepairAndMaintenanceViewModel> serviceRequestModel)
        {
            var mapped = _mapper.Map <RepairAndMaintenanceViewModel, RepairAndMaintenance>(serviceRequestModel.Model);

            mapped.Id          = Guid.NewGuid();
            mapped.CreatedDate = GeneralService.CurrentDate;
            mapped.CreatedById = serviceRequestModel.CurrentUserId.Value;
            mapped.Step        = 1;
            if (serviceRequestModel.LoginInfo.RoleId == new Guid(ApplicationConstants.AreaAdministratorRoleId) ||
                serviceRequestModel.LoginInfo.RoleId == new Guid(ApplicationConstants.AssistantAreaAdministratorRoleId))
            {
                mapped.BranchId = serviceRequestModel.Model.BranchId.Value;
            }

            else
            {
                mapped.BranchId = serviceRequestModel.LoginInfo.LoginUserBranches.FirstOrDefault().Id;
            }
            _genericUnitOfWork.GetRepository <RepairAndMaintenance, Guid>().Add(mapped);
            _genericUnitOfWork.SaveChanges();
            var emails = _sharedService.GetRepairAndMaintenanceProcessorEmails(BranchRequestType.Maintenance, mapped.Id);

            SendEmailToFirstStep(emails, new AdminNotificationViewModel()
            {
                Date           = mapped.CreatedDate.ToString("dd/MM/yyyy"),
                Sender         = _sharedService.GetUserFullName(mapped.CreatedById),
                ProcessingType = mapped.ProcessingStatus.ToString(),
                Category       = serviceRequestModel.Model.CategoryName,
                CategoryItem   = serviceRequestModel.Model.CategoryItemName,
                Quotations     = serviceRequestModel.Model.Quotations,
            });
        }