public bool UpdateDepartment(int DepartmentId, DepartmentEntities DepartmentEntities) { var success = false; if (DepartmentEntities != null) { //using (var scope = new TransactionScope()) //{ var DepartmentDetail = _UOW.DEPARTMENTRepository.GetByID(DepartmentId); if (DepartmentDetail != null) { if (DepartmentEntities.DEPARTMENT_NAME != null && DepartmentEntities.DEPARTMENT_NAME != "") { DepartmentDetail.DEPARTMENT_NAME = DepartmentEntities.DEPARTMENT_NAME; } _UOW.DEPARTMENTRepository.Update(DepartmentDetail); _UOW.Save(); cache.Remove(CacheKey); //scope.Complete(); success = true; //} } } return(success); }
public ActionResult Edit(int id, DepartmentEntities departmentEntity) { try { departmentManager.EditDepartment(id, departmentEntity); if (departmentEntity != null) { TempData["Update"] = "DepartmentEntity updated successfully"; } // for alert } catch (Exception e) // for error handling database action and show in bootstrap alert { #region Print error message on Index page in Bootstrap alert(danger) //if (e.Message != null) { TempData["Error"] = e.InnerException.InnerException.Message; } //else { TempData["Error"] = "Unknown"; } //return RedirectToAction("Index"); #endregion //Using ModelState Object to check Server side Validations string msg = e.InnerException.InnerException.Message; if (msg.Contains("Violation of UNIQUE KEY constraint")) { // ViewBag.UserEmailValidation = "User Email already exists. Please choose another Email."; ModelState.AddModelError("Code", "Department Code already exists. Please enter a different code."); return(View(departmentEntity)); } } return(RedirectToAction("Index")); }
// PUT api/department/5 public bool Put(int id, [FromBody] DepartmentEntities Department) { if (id > 0) { return(_Department.UpdateDepartment(id, Department)); } return(false); }
public Department EditDepartment(int id, DepartmentEntities departmenteEntity) { Department departmentUpdate = unitOfWork.DepartmentRepository.GetById(id); departmentUpdate.Name = departmenteEntity.Name; departmentUpdate.Code = departmenteEntity.Code; departmentUpdate.IsActive = departmenteEntity.Active; unitOfWork.Save(); return(departmentUpdate); }
public Department AddDepartment(DepartmentEntities departmenteEntity) { Department departmentAdd = new Department(); departmentAdd.Name = departmenteEntity.Name; departmentAdd.Code = departmenteEntity.Code; departmentAdd.IsActive = departmenteEntity.Active; unitOfWork.DepartmentRepository.Add(departmentAdd); unitOfWork.Save(); return(departmentAdd); }
public DepartmentEntities GetDepartment(int id) { Department department = unitOfWork.DepartmentRepository.GetById(id); DepartmentEntities departmentEntity = new DepartmentEntities(); departmentEntity.Id = department.Id; departmentEntity.Name = department.Name; departmentEntity.Code = department.Code; departmentEntity.Active = department.IsActive; return(departmentEntity); throw new NotImplementedException(); }
public int CreateDepartment(DepartmentEntities DepartmentEntities) { if (DepartmentEntities != null) { var DepartmentDetail = new TBL_HRMS_DEPARTMENTMASTER { DEPARTMENT_NAME = DepartmentEntities.DEPARTMENT_NAME, }; _UOW.DEPARTMENTRepository.Insert(DepartmentDetail); _UOW.Save(); cache.Remove(CacheKey); } return(Convert.ToInt32(DepartmentEntities.ID)); }
public async Task <ActionResult> DepartmentCreate(DepartmentEntities dept) { //if (ModelState.IsValid) //{ HttpResponseMessage responseMessage = await client.PostAsJsonAsync(url + "department", dept); if (responseMessage.IsSuccessStatusCode) { TempData["sucsmsg"] = "saved"; return(RedirectToAction("Index")); } return(RedirectToAction("Index")); }
public async Task <ActionResult> DepartmentEdit(DepartmentEntities dept, FormCollection fc) { int id = Convert.ToInt32(fc["rowid3"]); //if (ModelState.IsValid) //{ HttpResponseMessage responseMessage = await client.PutAsJsonAsync(url + "department/" + id, dept); if (responseMessage.IsSuccessStatusCode) { TempData["sucmsgupdate"] = "saved"; return(RedirectToAction("Index")); } return(RedirectToAction("Index")); }
public QueryAppsServices(HttpClient httpClient, IConfiguration config, ILogger <QueryAppsServices> logger) { _httpClient = httpClient; _logger = logger; _config = config.Load(); _awsBucket = _config.S3BucketName; _awsRegion = RegionEndpoint.GetBySystemName(_config.S3Region); var credentials = new BasicAWSCredentials(_config.S3AccessKeyID, _config.S3SecretAccessKey); var s3Config = new AmazonS3Config { RegionEndpoint = _awsRegion }; _s3Client = new AmazonS3Client(credentials, s3Config); _departmentEntities = new DepartmentEntities(config); }
public IEnumerable <DepartmentEntities> AllDepartments() { List <DepartmentEntities> listDepartmentEntities = new List <DepartmentEntities>(); List <Department> listDepartments = unitOfWork.DepartmentRepository.GetAll().ToList(); foreach (Department d in listDepartments) { DepartmentEntities departmentEntity = new DepartmentEntities(); EmployeeEntities employeeEntities = new EmployeeEntities(); departmentEntity.Id = d.Id; departmentEntity.Name = d.Name; departmentEntity.Code = d.Code; departmentEntity.Active = d.IsActive; departmentEntity.EmployeeNames = string.Join(", ", d.Employees.Select(e => e.Name).ToArray()); listDepartmentEntities.Add(departmentEntity); } return(listDepartmentEntities); }
void Initialize() { var depts = DeptCatcher.GetEntities().EntityList; var types = EqpTypeCatcher.GetEntities().EntityList; foreach (var dept in depts) { DepartmentEntities.Add(new ReqRpt047DepartmentEntity() { Department = dept.Department, EqpTypes = dept.Types.Split(',').ToList() }); } foreach (var type in types) { EqpTypeEntities.Add(new ReqRpt047EqpTypeEntity() { EqpType = type.Eqp_Type, Eqps = type.Eqps.Split(',').ToList() }); } }
public ActionResult Insert(FormCollection f) { string msg; try { DepartmentEntities OE = new DepartmentEntities(); tbl_Department D = new tbl_Department(); D.D_Name = f["DName"].ToString(); D.HOD = f["HOD"].ToString(); OE.tbl_Department.Add(D); OE.SaveChanges(); msg = "Record is Inserted"; } catch { msg = "Record not inserted"; } TempData["msg"] = msg; TempData.Keep();//or TempData.Keep("msg") for a particular msg to be kept in temp data return(RedirectToAction("Index")); }
public JsonResult CreateDepartment(DepartmentEntities de) { string res = ""; try { int Add_By = Convert.ToInt32(Session["Emp_id"].ToString()); DateTime Add_Date = DateTime.Today; int Deleted = 0; res = dblayer.CreateDepartment(de.Department_Code, de.Department_Name, de.Division_Code, de.Division_Name, Add_By, Add_Date, de.Status, Deleted); if (res == "Success") { mm.SuccessMsg = de.Department_Code.ToUpper() + " is successfully created."; } else { mm.ErrorMsg = res; } } catch (Exception ex) { } return(Json(mm, JsonRequestBehavior.AllowGet)); }
public IEnumerable <DepartmentEntities> AllDepartments() { List <DepartmentEntities> listDepartmentEntities = new List <DepartmentEntities>(); List <Department> listDepartments = unitOfWork.DepartmentRepository.GetAll().ToList(); foreach (Department d in listDepartments) { DepartmentEntities departmentEntity = new DepartmentEntities(); EmployeeEntities employeeEntities = new EmployeeEntities(); departmentEntity.Id = d.Id; departmentEntity.Name = d.Name; departmentEntity.Code = d.Code; departmentEntity.Active = d.IsActive; departmentEntity.EmployeeNames = string.Join(", ", d.Employees.Select(e => e.Name).ToArray()); //Get comma separated employee names //object[] array = new object[] { };//Using display comma separated those EmployeeNames which have same departments //array = employeeDepartment.Employees.Where(e => e.DepartmentId == d.Id).Select(e => e.Name).ToArray(); //departmentEntity.EmployeeNames = string.Join(", ", array); //departmentEntity.EmployeeNames = unitOfWork.EmployeeRepository.EmployeeNames(d.Id);//Using display comma separated listDepartmentEntities.Add(departmentEntity); } return(listDepartmentEntities); }
// POST api/department public int Post([FromBody] DepartmentEntities Department) { return(_Department.CreateDepartment(Department)); }
public HealthCheckServices(IConfiguration config) { _config = config.Load(); _departmentEntities = new DepartmentEntities(config); }
// GET: Department/Create public ActionResult Create() { DepartmentEntities departmentEntity = new DepartmentEntities(); return(View(departmentEntity)); }