Beispiel #1
0
        public IActionResult PostDepartment(DepartmentVM vm)
        {
            try
            {
                var current = _mapper.Map <Departments>(vm);

                if (vm.Id == 0)
                {
                    int result = _depBll.Insert(current);

                    if (result != 1)
                    {
                        return(Json(new { add = true, done = false, message = "Error in Save" }));
                    }

                    return(Json(new { add = true, done = true, message = "Added Successfully" }));
                }
                else
                {
                    int result = _depBll.Update(current);

                    if (result != 1)
                    {
                        return(Json(new { edit = true, done = false, message = "Error in Update" }));
                    }

                    return(Json(new { edit = true, done = true, message = "Updated Successfully" }));
                }
            }
            catch (Exception x)
            {
                return(Json(new { done = false, message = $"{x.InnerException?.Message ?? x.Message}" }));
            }
        }
 public JArray PutDepartment(Departments obj)
 {
     try
     {
         _departments.Update(obj);
         return(GetDepartment());
         //IList<Departments> objDepartmentses = new List<Departments>();
         //objDepartmentses = _departments.GetAllData();
         //return JArray.Parse(objDepartmentses.ToJson(new JsonWriterSettings { OutputMode = JsonOutputMode.Strict }));
     }
     catch (Exception)
     {
         throw;
     }
 }