public HttpResponseMessage GetEmploymentTypeModels(EmploymentTypeModel model)
 {
     try
     {
         if (this.ModelState.IsValid)
         {
             var EmploymentTypeList = _employmentTypeService.GetAllEmploymentTypeList(model);
             if (EmploymentTypeList != null)
             {
                 return(Request.CreateResponse(HttpStatusCode.OK, EmploymentTypeList));
             }
             else
             {
                 string message = "Error in getting Data";
                 return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
             }
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.InnerException.Message));
     }
 }
 public HttpResponseMessage DeleteEmploymentType(EmploymentTypeModel model)
 {
     try
     {
         if (this.ModelState.IsValid)
         {
             var result = _employmentTypeService.DeleteEmploymentType(model);
             if (result != null)
             {
                 return(Request.CreateResponse(HttpStatusCode.OK, result));
             }
             else
             {
                 string message = "Not deleted successfully";
                 return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
             }
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
     }
 }
Esempio n. 3
0
        public void Create(EmploymentTypeModel model, out Guid employmentTypeId)
        {
            if (this._repoEmploymentType.Query().Filter(x => x.code == model.code).Get().Any())
            {
                throw new Exception(model.code + " is already exists");
            }
            var currentUserId = this.GetCurrentUserId();
            var ins           = this._repoEmploymentType.Insert(new mf_EmploymentType()
            {
                code        = model.code,
                description = model.description,
                updatedBy   = currentUserId,
            });

            this._unitOfWork.Save();
            employmentTypeId = ins.id;
        }
Esempio n. 4
0
        public void Update(EmploymentTypeModel model)
        {
            var upt = this._repoEmploymentType.Find(model.id);

            if (upt.code != model.code)
            {
                if (this._repoEmploymentType.Query().Filter(x => x.code == model.code).Get().Any())
                {
                    throw new Exception(model.code + " is already exists");
                }
                upt.code = model.code;
            }
            upt.description = model.description;
            upt.updatedBy   = this.GetCurrentUserId();
            upt.updatedDate = DateTime.Now;
            this._repoEmploymentType.Update(upt);
            this._unitOfWork.Save();
        }
Esempio n. 5
0
        public ActionResult EmploymentTypeCRUD([DataSourceRequest] DataSourceRequest request
                                               , UpdateType updateType
                                               , EmploymentTypeModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                try
                {
                    switch (updateType)
                    {
                    case UpdateType.Create:
                        Guid employmentTypeId;
                        this._employmentTypeService.Create(model, out employmentTypeId);
                        model.id = employmentTypeId;
                        break;

                    case UpdateType.Update:
                        this._employmentTypeService.Update(model);
                        break;

                    case UpdateType.Destroy:
                        this._employmentTypeService.Delete(model.id.Value);
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception ex)
                {
                    this.AddModelError(ex);
                }
            }
            if (model.id.HasValue && updateType != UpdateType.Destroy)
            {
                model = this._employmentTypeService.GetById(model.id.Value);
            }
            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }