public JsonModel AddUpdateMasterServiceType(MasterServiceTypeDTO masterServiceTypeDTO, TokenModel token)
        {
            JsonModel Result = new JsonModel()
            {
                data       = false,
                Message    = StatusMessage.Success,
                StatusCode = (int)HttpStatusCodes.OK
            };
            MasterServiceType masterServiceTypeEntity = null;
            DateTime          CurrentDate             = DateTime.UtcNow;

            if (masterServiceTypeDTO.Id == 0 || masterServiceTypeDTO.Id == null)
            {
                masterServiceTypeEntity = _mapper.Map <MasterServiceType>(masterServiceTypeDTO);
                masterServiceTypeEntity.OrganizationId = 2; // token.OrganizationID;
                masterServiceTypeEntity.CreatedBy      = 2; // token.UserID;
                masterServiceTypeEntity.CreatedDate    = CurrentDate;
                masterServiceTypeEntity.IsActive       = true;
                _masterServiceTypeRepository.Create(masterServiceTypeEntity);
                _masterServiceTypeRepository.SaveChanges();
            }

            else
            {
                MasterServiceType masterServiceType = _masterServiceTypeRepository.Get(l => l.Id == masterServiceTypeDTO.Id && l.OrganizationId == 2); // token.OrganizationID);
                masterServiceType.UpdatedBy   = 2;                                                                                                     // token.UserID;
                masterServiceType.UpdatedDate = CurrentDate;
                masterServiceType.ServiceType = masterServiceTypeDTO.ServiceType;
                _masterServiceTypeRepository.Update(masterServiceType);
                _masterServiceTypeRepository.SaveChanges();
            }

            return(Result);
        }
Пример #2
0
 public ActionResult SaveMasterServiceType(MasterServiceTypeDTO masterServiceTypeDTO)
 {
     return(Ok(_masterServiceType.AddUpdateMasterServiceType(masterServiceTypeDTO, GetToken(HttpContext))));
 }