public ActionResult ViewStatus(LeaveDto leavedto) { HttpClient client = new HttpClient(); var param = JsonConvert.SerializeObject(leavedto); HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json"); client.BaseAddress = new Uri("http://localhost:60073/api/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = client.PostAsync(string.Format("Employee/ViewStatus"), contentPost).Result; string stringData = response.Content.ReadAsStringAsync().Result; List <LeaveDto> leaves = JsonConvert.DeserializeObject <List <LeaveDto> >(stringData); foreach (var item in leaves) { if (item.Status == "Approve") { item.Status = "Approved"; } else if (item.Status == "Reject") { item.Status = "Rejected"; } } return(View("DisplayStatus", leaves)); }
public async Task <ActionResult <bool> > AddLeave(LeaveDto leaveDto) { var leave = _mapper.Map <LeaveDto, Leave>(leaveDto); _unitOfWork.Repository <Leave>().Add(leave); return(await _unitOfWork.Complete() > 0); }
public async Task <ServiceResult <Guid> > Add(LeaveDto leaveDto) { var leave = _mapper.Map <Leave>(leaveDto); _context.Leaves.Add(leave); await _context.SaveChangesAsync(); return(new ServiceResult <Guid> { Data = leave.LeaveId }); }
public ActionResult Delete(LeaveDto leavedto) { HttpClient client = new HttpClient(); var id = leavedto.Id; client.BaseAddress = new Uri("http://localhost:60073//api/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = client.DeleteAsync(string.Format("Employee/Delete?id=" + id)).Result; string stringData = response.Content.ReadAsStringAsync().Result; List <LeaveDto> leaves = JsonConvert.DeserializeObject <List <LeaveDto> >(stringData); return(View("DisplayStatus", leaves)); }
public ActionResult LeaveForm(Guid Id) { var dto = new LeaveDto { CreatorUserId = Operator.UserId, CreatorUserName = Operator.UserName }; if (Guid.Empty != Id) { var model = FormContract.Leaves.Where(c => c.Id == Id).Select(m => new { m.TypeVal, m.Reason, m.StartTime, m.EndTime,m.CreatorUserId,m.CreatedTime }).FirstOrDefault(); dto.Id = Id; dto.CreatorUserId = model.CreatorUserId; dto.TypeVal = model.TypeVal; dto.Reason = model.Reason; } dto.StartTime = dto.StartTime == DateTime.MinValue ? DateTime.Now : dto.StartTime; dto.EndTime = dto.EndTime == DateTime.MinValue ? DateTime.Now : dto.EndTime; dto.TypeHtml = CommonContract.GetDropdownOptionHtml("QJLX"); return View(dto); }
public ActionResult ChangeStatus(LeaveDto leavedto) { HttpClient client = new HttpClient(); var param = JsonConvert.SerializeObject(leavedto); HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json"); client.BaseAddress = new Uri("http://localhost:60073/api/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = client.PostAsync(string.Format("Employee/ChangeStatus"), contentPost).Result; string stringData = response.Content.ReadAsStringAsync().Result; EmployeeDto employees = JsonConvert.DeserializeObject <EmployeeDto>(stringData); return(View("HrHome", employees)); }
public ActionResult EditLeave(LeaveDto leavedto) { leavedto.EmpTableId = (int)Session["EmployeeTableId"]; HttpClient client = new HttpClient(); var param = JsonConvert.SerializeObject(leavedto); HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json"); client.BaseAddress = new Uri("http://localhost:60073/api/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = client.PutAsync(string.Format("Employee/EditLeave"), contentPost).Result; string stringData = response.Content.ReadAsStringAsync().Result; List <LeaveDto> leaves = JsonConvert.DeserializeObject <List <LeaveDto> >(stringData); return(View("DisplayStatus", leaves)); }
public ActionResult SaveLeave(LeaveDto dtos) { OperationResult result; if (dtos.Id == Guid.Empty) { dtos.Id = CombHelper.NewComb(); result = FormContract.AddLeave(dtos); result.Data = new { EntityId = dtos.Id }; } else { result = FormContract.EditLeave(dtos); result.Data = new { EntityId = dtos.Id }; } return(Json(result.ToAjaxResult(), JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> UpdateLeave(int id, [FromBody] LeaveDto createLeaveDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var leaveX = await _context.Leaves.SingleOrDefaultAsync(x => x.Id == id); leaveX.LastUpdated = DateTime.Now; _mapper.Map(createLeaveDto, leaveX); await _context.SaveChangesAsync(); var result = _mapper.Map <Leave, LeaveDto>(leaveX); return(Ok(result)); }
public ActionResult AddLeave(LeaveDto leavedto) { leavedto.EmpTableId = (int)Session["EmployeeTableId"]; HttpClient client = new HttpClient(); var param = JsonConvert.SerializeObject(leavedto); HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json"); client.BaseAddress = new Uri("http://localhost:60073/api/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = client.PostAsync(string.Format("Leave/AddLeave"), contentPost).Result; if (response.IsSuccessStatusCode) { EmployeeDto employees = Session["Employees"] as EmployeeDto; return(View("EmployeeHome", employees)); } return(View("Index")); }
public ActionResult LeaveForm(Guid Id) { var dto = new LeaveDto { CreatorUserId = Operator.UserId, CreatorUserName = Operator.UserName }; if (Guid.Empty != Id) { var model = FormContract.Leaves.Where(c => c.Id == Id).Select(m => new { m.TypeVal, m.Reason, m.StartTime, m.EndTime, m.CreatorUserId, m.CreatedTime }).FirstOrDefault(); dto.Id = Id; dto.CreatorUserId = model.CreatorUserId; dto.TypeVal = model.TypeVal; dto.Reason = model.Reason; } dto.StartTime = dto.StartTime == DateTime.MinValue ? DateTime.Now : dto.StartTime; dto.EndTime = dto.EndTime == DateTime.MinValue ? DateTime.Now : dto.EndTime; dto.TypeHtml = CommonContract.GetDropdownOptionHtml("QJLX"); return(View(dto)); }
public async Task <IActionResult> CreateLeave([FromBody] LeaveDto createLeaveDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var leave = _mapper.Map <LeaveDto, Leave>(createLeaveDto); leave.LastUpdated = DateTime.Now; leave.IsApproved = false; _context.Leaves.Add(leave); await _context.SaveChangesAsync(); var result = _mapper.Map <Leave, LeaveDto>(leave); return(Ok(result)); }
public ActionResult <LeaveDto> AddLeaveForEmployee(string empId, [FromBody] LeaveDto leaveDto) { //if(leaveDto == null) //{ // return NotFound(); //} if (!_repo.EmployeeExists(empId)) { //need to send custom error message in response -- pending return(NotFound()); } var entityLeave = _mapper.Map <Leave>(leaveDto); _repo.AddLeave(empId, entityLeave); _repo.Save(); var leaveToReturn = _mapper.Map <LeaveDto>(entityLeave); return(CreatedAtRoute("GetLeaveForEmployee", new { empId = empId, leaveId = leaveToReturn.LeaveEntryId }, leaveToReturn)); }
public ActionResult SaveLeave(LeaveDto dtos) { OperationResult result ; if(dtos.Id==Guid.Empty){ dtos.Id = CombHelper.NewComb(); result = FormContract.AddLeave(dtos); result.Data = new { EntityId = dtos.Id }; } else { result = FormContract.EditLeave(dtos); result.Data = new { EntityId = dtos.Id }; } return Json(result.ToAjaxResult(),JsonRequestBehavior.AllowGet); }