Example #1
0
        public string InsertUpdateDepartment(DepartmentViewModel departmentViewModel)
        {
            object result = null;

            try
            {
                AppUA _appUA = Session["AppUA"] as AppUA;
                departmentViewModel.commonObj             = new CommonViewModel();
                departmentViewModel.commonObj.CreatedBy   = _appUA.UserName;
                departmentViewModel.commonObj.CreatedDate = _appUA.DateTime;
                departmentViewModel.commonObj.UpdatedBy   = departmentViewModel.commonObj.CreatedBy;
                departmentViewModel.commonObj.UpdatedDate = departmentViewModel.commonObj.CreatedDate;
                switch (departmentViewModel.Operation)
                {
                case "Insert":
                    result = _departmentBusiness.InsertDepartment(Mapper.Map <DepartmentViewModel, Department>(departmentViewModel));
                    break;

                case "Update":
                    result = _departmentBusiness.UpdateDepartment(Mapper.Map <DepartmentViewModel, Department>(departmentViewModel));
                    break;
                }

                return(JsonConvert.SerializeObject(new { Result = "OK", Record = result }));
            }
            catch (Exception ex)
            {
                AppConstMessage cm = c.GetMessage(ex.Message);
                return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = cm.Message }));
            }
        }