public async Task<ActionResult> Create(DepartmentModel departmentModel)
 {
     if (!ModelState.IsValid)
     {
         return RedirectToAction("BadRequest", "Error");
     }
     var guid = await PostJsonAsyc("api/departments", departmentModel);
     return RedirectToAction("Details", "Departments", new {id = guid});
 }
Esempio n. 2
0
        public ActionResult Create()
        {
            using (var db = new NespeDbContext())
            {
                var drc = db.DepartmentSet;

                var model = new DepartmentModel { Selected = new Department { }};
                model.Items = (from t in drc select t).ToList();
                return View(model);
            }
        }
Esempio n. 3
0
 public bool Save(DepartmentModel category)
 {
     try
     {
         var query       = "INSERT INTO tblDepartment (Code, Department) VALUES('" + category.Code + "','" + category.Department + "')";
         var rowAffected = _sDB.ExecuteNonQuery(query, _connectionString);
         return(rowAffected > 0);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
        public ActionResult Edit(DepartmentModel model)
        {
            var orignalmodel = DepartmentService.ReadModel(model.Id);

            model.UpdateBy = Operator.UserId;
            model.UpdateOn = DateTime.Now;
            model.CreateBy = orignalmodel.CreateBy;
            model.CreateOn = orignalmodel.CreateOn;

            var result = DepartmentService.UpdateModel(model) ? SuccessTip() : ErrorTip();

            return(Json(result));
        }
Esempio n. 5
0
 public ActionResult Departments(DepartmentModel model)
 {
     if (ModelState.IsValid)
     {
         int id = departmentInformation.AddDepartmentName(model);
         if (id > 0)
         {
             ModelState.Clear();
             ViewBag.Success = "Data inserted";
         }
     }
     return(View());
 }
Esempio n. 6
0
 public string UpdateDepartment(DepartmentModel data, int id)
 {
     try
     {
         var conn = _connect.ConexionABase();
         conn.Query <DepartmentModel>($"UPDATE [dbo].[Departments] SET Name='{data.Name}', Description='{data.Description}' WHERE id='{id}'");
         return("OK");
     }
     catch (Exception)
     {
         throw;
     }
 }
        public ActionResult DeleteDepartment(int?Id)
        {
            if (Id != null)
            {
                DepartmentModel objDepartment = new DepartmentModel();
                objDepartment.DeleteDepartment(Convert.ToInt32(Id));
            }
            Sal_Dept_DesigModel objSal_Dept_Desig = new Sal_Dept_DesigModel();

            BingModelData(objSal_Dept_Desig);

            return(View("~/Views/sal_Dept_Desig/Index.cshtml", objSal_Dept_Desig));
        }
Esempio n. 8
0
 public string CreateDepartment(DepartmentModel data)
 {
     try
     {
         var conn = _connect.ConexionABase();
         conn.Query <DepartmentModel>($"Insert into [dbo].[Departments] VALUES ('{data.Name}','{data.Description}')");
         return("OK");
     }
     catch (Exception)
     {
         throw;
     }
 }
 public bool UpdateDepartment(DepartmentModel model)
 {
     if (model.DepartmentId == -1)
     {
         model.DepartmentId = null;
         return(_serviceFactory.Department.Create(model));
     }
     else
     {
         string[] ignores = WebConstants.SharedTrainings;
         return(_serviceFactory.Department.Update(model, ignores));
     }
 }
Esempio n. 10
0
        public ActionResult EditDepartment(int id = 0)
        {
            var department = new DepartmentModel();

            if (id != 0)
            {
                var EditDepartment = _Context.Departments.Where(x => x.Id == id).Select(x => x).SingleOrDefault();

                department.Id      = EditDepartment.Id;
                department.DepName = EditDepartment.DepName;
            }
            return(View(department));
        }
Esempio n. 11
0
        public int InsertDepartment(DepartmentModel saveDepartment)
        {
            SqlConnection con   = new SqlConnection(connectionString);
            string        query = "insert into Department values('" + saveDepartment.Name + "','" +
                                  saveDepartment.Code + "')";
            SqlCommand cmd = new SqlCommand(query, con);

            con.Open();
            int rowAffect = cmd.ExecuteNonQuery();

            con.Close();
            return(rowAffect);
        }
        public static DepartmentModel toModel(Department entity)
        {
            DepartmentModel model = new DepartmentModel();

            if (entity != null)
            {
                model.token          = entity.token;
                model.DepartmentName = entity.DepartmentName;
                model.Address        = entity.Address;
                model.Employees      = entity.Employees.Select(a => EmployeeMapper.toModel(a)).ToList();
            }
            return(model);
        }
        public string Save(DepartmentModel department)
        {
            int rowEffect = departmentGateway.Save(department);

            if (rowEffect > 0)
            {
                return("Save Successful");
            }
            else
            {
                return("Save Faild");
            }
        }
Esempio n. 14
0
        public void Update(DepartmentModel model)
        {
            var data = departmentRepository.FindBy(x => x.departmentId == model.departmentId);

            if (data != null)
            {
                data.departmentname     = model.departmentname;
                data.description        = model.description;
                data.updated_on         = DateTime.Now;
                data.VisibleOnDashboard = model.VisibleOnDashboard;
                departmentRepository.Update(data);
            }
        }
        public ActionResult Edit(int Id)
        {
            DepartmentModel departmentModel = _departmentModelRepository.GetbyId(Id);

            if (departmentModel == null)
            {
                return(HttpNotFound());
            }
            else
            {
                return(View(departmentModel));
            }
        }
Esempio n. 16
0
        public bool Delete(DepartmentModel entity)
        {
            bool result = false;

            using (var db = new ListerHaighEntites())
            {
                var department = db.Departments.FirstOrDefault(x => x.DepartmentId == entity.DepartmentId);
                db.Entry <Department>(department).State = EntityState.Deleted;
                result = (db.SaveChanges() > 0 ? false : true);
            }

            return(result);
        }
Esempio n. 17
0
        public bool IsDepartmentTestExists(DepartmentModel aDepartmentModel)
        {
            DepartmentModel existingDepartment = departmentGateway.GetDepartmentByDeptCode(aDepartmentModel.DepartmentCode);

            if (existingDepartment != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public IActionResult Update(DepartmentModel model)
        {
            Department e = companyDB.Departments.Find(model.department.id);

            if (null == e)
            {
                return(NotFound());
            }

            companyDB.Departments.Update(e);
            companyDB.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 19
0
        public ActionResult CreateDepartment(DepartmentModel model)
        {
            //checking if the data sent from the form is valid
            if (ModelState.IsValid)
            {
                DataLibrary.BusinessLogic.DepartmentProcessor.CreateDepartment(model.OrgCode, model.departmentname, model.UWCoordinator3, model.UWCoordinator2, model.UWCoordinator1, model.Division,
                                                                               model.DepartmentStatus, model.DepartmentDateCreated, model.DepartmentLastEdited);
                return(RedirectToAction("Department"));
            }

            ModelState.Clear();
            return(View());
        }
Esempio n. 20
0
        private void _Delete()
        {
            msg = "";
            DepartmentModel dpt    = new DepartmentModel();
            DepartmentDAL   objDal = new DepartmentDAL();

            dpt.DepartmentId = Convert.ToInt32(HdnDepartmentId.Value);
            msg = objDal._insertUpdateDeleteDepartment(dpt, "Delete");
            if (msg != "")
            {
                _Refresh();
            }
        }
        public ActionResult Edit([Bind(Include = "ID,Name,CreatedBy,CreatedDate,UpdatedBy,UpdatedDate")] DepartmentModel departmentModel)
        {
            if (ModelState.IsValid)
            {
                departmentModel.UpdatedBy   = context.UserID;
                departmentModel.UpdatedDate = DateTime.Now;

                db.Entry(departmentModel).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(departmentModel));
        }
Esempio n. 22
0
        public async Task <DepartmentModel> GetDepartmentById(int departmentId)
        {
            DepartmentModel departmentModel = null;

            IList <DepartmentModel> departmentModelList = await GetDepartmentList(departmentId);

            if (null != departmentModelList && departmentModelList.Any())
            {
                departmentModel = departmentModelList.FirstOrDefault();
            }

            return(departmentModel); // returns.
        }
 public ActionResult TicketView(int t_id)
 {
     TicketViewModel tvm = new TicketViewModel();
     tvm.Ticket_No = t_id;
     ComplainRegistrationModel complainRegistrationModel=db.Complains.Find(t_id);
     tvm.UserName = complainRegistrationModel.UserName;
     DepartmentModel dpt = db.Departments.Find(complainRegistrationModel.DepartmentID);
     tvm.DepartmentName = dpt.Name;
     tvm.Location = dpt.Location;
     tvm.HODName = dpt.HeadOfDepartment;
     tvm.Contact_NO = dpt.ContactNo;
     return View(tvm);
 }
Esempio n. 24
0
 //构造方法
 public DepartmentService()
 {
     try {
         //获取token
         string token = FinanceToken.getFinanceCheckToken().getToken();
         //获取对象
         account = FinanceToken.getFinanceCheckToken().checkToken(token);
         //实例化model层
         departmentModel = new DepartmentModel();
     }catch {
         throw new InvalidOperationException("身份验证不通过");
     }
 }
Esempio n. 25
0
        /// <summary>
        /// 取得部門資訊
        /// </summary>
        /// <param name="depId"></param>
        /// <returns></returns>
        public DepartmentModel GetDepartmentInfoByID(string depId)
        {
            DepartmentModel dep     = new DepartmentModel();
            var             depInfo = this.DB.Department.Where(o => o.DepartmentID == depId).FirstOrDefault();

            if (depInfo == null)
            {
                throw new Exception("無法取得部門資訊");
            }
            dep.ID   = depInfo.DepartmentID;
            dep.Name = depInfo.DepartmentName;
            return(dep);
        }
        /// <summary>
        /// 查询组织结构相关的用户
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult GetDepUserData(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(null);
            }
            DepartmentModel model = new DepartmentModel();

            model.Id = Convert.ToInt32(id);
            List <ViewDepUserModel> list = organizationManager.GetDepUserData(model);

            return(JsonNT(list));
        }
        public IHttpActionResult DeleteDepartment(DepartmentModel departmentModel)
        {
            var result = obj.DeleteDepartment(departmentModel);

            if (result == 1)
            {
                return(this.Ok("Department deleted Successfully"));
            }
            else
            {
                return(this.BadRequest("Department Could not be Deleted"));
            }
        }
Esempio n. 28
0
        public HttpResponseMessage AddDepartment(DepartmentModel model)
        {
            try
            {
                departmentBusiness.AddDepartment(model);

                return(Request.CreateResponse(HttpStatusCode.OK, Constants.OK));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Esempio n. 29
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //Kiểm tra validate để chuẩn bị cho thao tác
                if (checkValid())
                {
                    //Khai báo một model của bảng Department trong cơ sở dữ liệu
                    DepartmentModel dModel;
                    if (_isAdd)//nếu bạn muốn Insert một bản ghi
                    {
                        dModel             = new DepartmentModel();
                        dModel.CreatedDate = TextUtils.GetSystemDate();
                        dModel.UpdatedDate = dModel.CreatedDate;
                        dModel.CreatedBy   = Global.AppUserName;
                        dModel.UpdatedBy   = Global.AppUserName;
                    }
                    else
                    {
                        //nếu bạn muốn update một bản ghi
                        int ID = TextUtils.ToInt(grvData.GetRowCellValue(grvData.FocusedRowHandle, "ID"));
                        dModel             = (DepartmentModel)DepartmentBO.Instance.FindByPK(ID);
                        dModel.UpdatedDate = TextUtils.GetSystemDate();
                        dModel.UpdatedBy   = Global.AppUserName;
                    }
                    //gán các giá trị vào các trường để phục vụ việc thêm, sửa
                    dModel.Code             = txtCode.Text;
                    dModel.Name             = txtName.Text;
                    dModel.Status           = cboStatus.SelectedIndex;
                    dModel.Email            = txtEmail.Text;
                    dModel.HeadofDepartment = TextUtils.ToInt(leHead.EditValue);

                    if (_isAdd)
                    {
                        //lệnh này tương tự với câu lệnh insert trong sql
                        DepartmentBO.Instance.Insert(dModel);
                    }
                    else
                    {
                        DepartmentBO.Instance.Update(dModel);//lệnh này tương tự với câu lệnh update trong sql
                    }
                    LoadData();
                    SetInterface(false);
                    ClearInterface();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 30
0
        private void querys()
        {
            DepartmentModel dm = new DepartmentModel();
            EmployeeModel   em = new EmployeeModel();

            //Department
            gv1.DataSource = dm.query01();
            gv1.DataBind();
            gv2.DataSource = dm.query02();
            gv2.DataBind();
            gv3.DataSource = dm.query03();
            gv3.DataBind();
            gv4.DataSource = dm.query04();
            gv4.DataBind();
            gv5.DataSource = dm.query05();
            gv5.DataBind();

            //Empoyee
            gv6.DataSource = em.query06();
            gv6.DataBind();
            gv7.DataSource = em.query07();
            gv7.DataBind();

            //Department
            gv8.DataSource = dm.query08();
            gv8.DataBind();

            //employee
            gv9.DataSource = em.query09();
            gv9.DataBind();
            gv10.DataSource = em.query10();
            gv10.DataBind();
            gv11.DataSource = em.query11();
            gv11.DataBind();
            gv12.DataSource = em.query12();
            gv12.DataBind();
            gv13.DataSource = em.query13();
            gv13.DataBind();
            gv14.DataSource = em.query14();
            gv14.DataBind();
            gv15.DataSource = em.query15();
            gv15.DataBind();

            //department
            gv16.DataSource = dm.query16();
            gv16.DataBind();

            //employee
            gv17.DataSource = em.query17();
            gv17.DataBind();
        }
        public async Task <ActionResult> Create(DepartmentViewModel model, HttpPostedFileBase fileUpload)
        {
            if (!await APIProvider.Authorization(_userSession.BearerToken, ARS.Insert))
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.FuntionType.Department, APIConstant.ACTION_INSERT);
                return(RedirectToAction("Index"));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    if (fileUpload != null)
                    {
                        model.Img = fileUpload.FileName;
                    }

                    //Call API Provider
                    string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_INSERT);
                    var    result = await APIProvider.Authorize_DynamicTransaction <DepartmentViewModel, bool>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Insert);

                    if (result)
                    {
                        if (fileUpload != null)
                        {
                            FileManagement.UploadImage(fileUpload, ValueConstant.IMAGE_DEPARTMENT_PATH);
                        }

                        TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.SUCCESS));
                    }
                    else
                    {
                        TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                    }
                    return(RedirectToAction("Index"));
                }
                else
                {
                    var department = new DepartmentModel();
                    department.lstDepartmentViewModel = (List <DepartmentViewModel>)TempData["Data"];

                    if (department.lstDepartmentViewModel == null)
                    {
                        department.lstDepartmentViewModel = ApplicationGenerator.GetObject <List <DepartmentViewModel> >();
                    }
                    department.DepartmentViewModel = model;

                    //TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                    return(View("Index", department));
                }
            }
        }
        public bool IsNameExists(DepartmentModel department)
        {
            query = "SELECT * FROM DepartmentTable WHERE Name=@Name";

            Command = new SqlCommand(query, Connection);
            Command.Parameters.AddWithValue("@Name", department.Name);

            Connection.Open();
            Reader = Command.ExecuteReader();
            bool hasRows = Reader.HasRows;

            Connection.Close();
            return(hasRows);
        }
 public async Task<ActionResult> Edit(DepartmentModel departmentModel)
 {
     var requestUri = string.Format("api/departments/{0}", departmentModel.Id);
     if (!ModelState.IsValid) throw new HttpException((int) HttpStatusCode.BadRequest, "Error");
     var updated = await PutJsonAsyc(requestUri, departmentModel);
     switch (updated.Type)
     {
         case ResultType.DbUpdateConcurrencyException:
             return RedirectToAction("Edit", new { id = departmentModel.Id, concurrencyError = true });
         case ResultType.DataException:
             ModelState.AddModelError(string.Empty,
                 "Unable to edit. Try again, and if the problem persists contact your system administrator.");
             return View(departmentModel);
     }
     return RedirectToAction("Details", "Departments", new {id = updated.Value});
 }
Esempio n. 34
0
 public ActionResult Delete(long Id)
 {
     using (var db = new NespeDbContext())
     {
         var drc = db.DepartmentSet;
         var dr = (from t in drc where t.Id == Id select t).FirstOrDefault();
         if (dr == null)
         {
             base.ModelState.AddModelError("Action.Delete.Invalid.Id", "Invalid Id");
             return RedirectToAction("Index");
         }
         var model = new DepartmentModel { Selected = dr };
         model.Items = (from t in drc select t).ToList();
         return View(model);
     }
 }
Esempio n. 35
0
 public ActionResult Delete(DepartmentModel model, FormCollection formCollection)
 {
     if (ModelState.IsValid)
     {
         using (var db = new NespeDbContext())
         {
             var drc = db.DepartmentSet;
             var dr = (from t in drc where t.Id == model.Selected.Id select t).FirstOrDefault();
             if (dr == null)
             {
                 base.ModelState.AddModelError("Action.Delete.Invalid.Id", "Invalid Id");
                 return RedirectToAction("Index");
             }
             model.Items = (from t in drc select t).ToList();
         }
         return RedirectToAction("Index");
     }
     return View(model);
 }
        public HttpResponseMessage Create(DepartmentModel departmentModel)
        {
            var result = new HttpResponseMessage();
            if (ModelState.IsValid)
            {
                try
                {
                    var newGuid = departmentService.Create(departmentModel);
                    result.StatusCode = HttpStatusCode.Created;
                    result.Content = new StringContent(newGuid.ToString());
                }
                catch
                {
                    result.StatusCode = HttpStatusCode.BadRequest;
                }

            }
            return result;
        }
Esempio n. 37
0
 public ActionResult Create(DepartmentModel model, FormCollection formCollection)
 {
     if (ModelState.IsValid)
     {
         using (var db = new NespeDbContext())
         {
             var drc = db.DepartmentSet;
             var dr = (from t in drc where t.Name == model.Selected.Name select t).FirstOrDefault();
             if (dr != null && dr.Id > 0)
             {
                 return RedirectToAction("Edit", new { Id = dr.Id });
             }
             else
             {
                 drc.Add(model.Selected);
             }
             db.SaveChanges();
             model.Items = (from t in drc select t).ToList();
         }
         return RedirectToAction("Index");
     }
     return View(model);
 }
        public string AddSub(EditDepartmentModel model)
        {
#if DEBUG
            UserModel user = UserModel.SingleOrDefault(14);
            SysConfig.CurrentUser = user;
#endif

            if (ModelState.IsValid)
            {
                DepartmentModel department = new DepartmentModel();
                department.Name = model.Name;                                                               //部门名称
                department.No = model.No;                                                                   //部门编号

                department.DocDepartment = model.DocDepartment.ToInt();                                     //是否业务部门
                department.Pid = model.Id;                                                                  //上级部门
                department.FullPid = model.FullPid + "-" + model.Id;                                        //所有上级部门

                department.FullName = CommonMethod.GetDepFullName(department.FullPid) + department.Name;    //部门全称
                department.Sortno = model.Sortno;                                                           //排序编号
                department.DepLevel = model.DepLevel + 1;                                                   //部门层级

                department.CreateMan = SysConfig.CurrentUser.Id;                                            //创建人
                department.CreateTime = DateTime.Now;                                                       //创建时间

                int result = (int)department.Insert();

                if (result > 0)
                {
                    //记录操作日志
                    CommonMethod.Log(SysConfig.CurrentUser.Id, "Insert", "Sys_Department");

                    return "1";
                }
            }

            return "0";
        }
Esempio n. 39
0
        static void Main(string[] args)
        {
            var path = AppDomain.CurrentDomain.BaseDirectory.Replace(@"\bin\Debug\", "");
            AppDomain.CurrentDomain.SetData("DataDirectory", path);

            //Recria banco, em caso de mudança
            Database.SetInitializer<SchoolEntities>(new DropCreateDatabaseIfModelChanges<SchoolEntities>());

            using (var SchoolEntities = new SchoolEntities())
            {
                var department = new DepartmentModel()
                {
                    Name = "Departament",
                    Budget = 10000,
                    StartDate = DateTime.Now
                };

                var course = new CourseModel()
                {
                    Title = "Title",
                    Credits = 10
                };

                var instrutor = new InstructorModel()
                {
                    FirstName = "FirstName",
                    LastName = "LastName",
                    HireDate = DateTime.Now
                };

                var office = new OfficeAssignmentModel()
                {
                    Location = "São Paulo",
                    Timestamp = BitConverter.GetBytes(DateTime.Now.ToOADate())
                };

                using (var transaction = SchoolEntities.Database.BeginTransaction())
                {

                    try
                    {

                        SchoolEntities.Departments.Add(department);
                        SchoolEntities.SaveChanges();

                        course.DepartmentID = SchoolEntities.Departments.ToList().Last().DepartmentID;
                        SchoolEntities.Courses.Add(course);
                        SchoolEntities.SaveChanges();

                        SchoolEntities.Instructors.Add(instrutor);
                        SchoolEntities.SaveChanges();

                        office.InstructorID = SchoolEntities.Instructors.ToList().Last().InstructorID;
                        SchoolEntities.OfficeAssignments.Add(office);
                        SchoolEntities.SaveChanges();

                        var loffice = SchoolEntities.OfficeAssignments.ToList();
                        SchoolEntities.OfficeAssignments.RemoveRange(loffice);
                        SchoolEntities.SaveChanges();

                        var linstrutor = SchoolEntities.Instructors.ToList();
                        SchoolEntities.Instructors.RemoveRange(linstrutor);
                        SchoolEntities.SaveChanges();

                        var lcourse = SchoolEntities.Courses.ToList();
                        SchoolEntities.Courses.RemoveRange(lcourse);
                        SchoolEntities.SaveChanges();

                        var ldepart = SchoolEntities.Departments.ToList();
                        SchoolEntities.Departments.RemoveRange(ldepart);
                        SchoolEntities.SaveChanges();

                        transaction.Commit();
                    }
                    catch
                    {
                        transaction.Rollback();
                    }
                }
            }
        }
Esempio n. 40
0
        public ActionResult Edit(DepartmentModel model, FormCollection formCollection)
        {
            if (ModelState.IsValid)
            {
                using (var db = new NespeDbContext())
                {
                    var selected = model.Selected;
                    var drc = db.DepartmentSet;
                    //drc.Attach(model.Selected);
                    var dr = (from t in drc where t.Id == model.Selected.Id select t).FirstOrDefault();
                    if (dr != null)
                    {
                        dr.Copy(selected);
                        selected = dr;
                    }
                    else
                        drc.Add(selected);

                    db.SaveChanges();

                }
                return RedirectToAction("Index");
            }
            using (var db = new NespeDbContext())
            {
                var drc = db.DepartmentSet;
                model.Items = (from t in drc select t).ToList();
                return View(model);
            }
        }
 public async Task<ActionResult> Reactivate(DepartmentModel deparmentModel)
 {
     var requestUri = string.Format("api/departments/{0}/activate?rowVersion={1}", deparmentModel.Id, deparmentModel.RowVersion.ByteArrayToString());
     var restored = await DeleteJsonAsyc(requestUri);
     switch (restored.Type)
     {
         case ResultType.DbUpdateConcurrencyException:
             return RedirectToAction("Restore", new { id = deparmentModel.Id, concurrencyError = true });
         case ResultType.DataException:
             ModelState.AddModelError(string.Empty,
                 "Unable to reactivate. Try again, and if the problem persists contact your system administrator.");
             return View(deparmentModel);
     }
     return RedirectToAction("Details","Departments", new{ id = deparmentModel.Id});
 }
 public HttpResponseMessage Edit(Guid id, DepartmentModel departmentModel)
 {
     var result = new HttpResponseMessage();
     if (ModelState.IsValid)
     {
         var updated = departmentService.Update(id, departmentModel);
         result.StatusCode = HttpStatusCode.OK;
         result.Content = new StringContent(JsonConvert.SerializeObject(updated));
     }
     else
     {
         result.StatusCode = HttpStatusCode.BadRequest;
     }
     return result;
 }