public RedirectToRouteResult Update(Review_Details reviewDetail) { if (reviewDetail.Reviewername == reviewDetail.Revieweename) { TempData["Message"] = "Reviewer and Reviewee should not be same"; return(RedirectToAction("DisplayMessages")); } int count = reviewDetailsBL.CheckLogic(reviewDetail); if (count == -5) { TempData["Message"] = "Already a review is scheduled on that day for reviewee"; return(RedirectToAction("DisplayMessages")); } else if (count == -4) { TempData["Message"] = "Already a review is scheduled on that day for reviewer"; return(RedirectToAction("DisplayMessages")); } else if (count == 0) { reviewDetailsBL.UpdateReview(reviewDetail); } return(RedirectToAction("DisplayReviewDetails")); }
public ActionResult Edit(int id) { Review_Details reviewDetail = reviewDetailsBL.GetReviewDetailsById(id); //ViewBag.Departments = new SelectList(departmentBL.GetDepartments(), "DepartmentID", "DepartmentName"); //ViewBag.Designation = new SelectList(designationBL.GetDesignations(), "DesignationID", "DesignationName"); List <SelectListItem> reviewerDepartments = new List <SelectListItem>(); ReviewDetailsViewModel reviewDetailsViewModel = new ReviewDetailsViewModel(); List <Departments> states = departmentBL.GetDepartments(); states.ForEach(x => { reviewerDepartments.Add(new SelectListItem { Text = x.DepartmentName, Value = x.DepartmentId.ToString() }); }); ViewBag.Departments = new SelectList(departmentBL.GetDepartments(), "DepartmentID", "DepartmentName"); reviewDetailsViewModel.Departments = reviewerDepartments; ReviewDetailsViewModel employeeViewModel = new ReviewDetailsViewModel(); // employeeViewModel = AutoMapper.Mapper.Map<ReviewDetail, ReviewDetailsViewModel>(reviewDetail); employeeViewModel.Id = reviewDetail.Id; employeeViewModel.Reviewername = reviewDetail.Reviewername; employeeViewModel.ReviewerDesignationId = reviewDetail.ReviewerDesignationId; employeeViewModel.ReviewerDepartmentId = reviewDetail.ReviewerDepartmentId; employeeViewModel.Revieweename = reviewDetail.Revieweename; employeeViewModel.RevieweeDesignationId = reviewDetail.RevieweeDesignationId; employeeViewModel.RevieweeDepartmentId = reviewDetail.RevieweeDepartmentId; employeeViewModel.Date = reviewDetail.Date; return(View(employeeViewModel)); }
//Method to add review details public int Add(Review_Details reviewDetail) { int count = 0; IList <Review_Details> li = null; List <Review_Details> review = null; using (EmployeeContext employeeContext = new EmployeeContext()) { review = employeeContext.Review_Detail.ToList(); li = review.FindAll(p => (p.Revieweename == reviewDetail.Reviewername && p.Date == reviewDetail.Date)); if (li.Count != 0) { count = -4; return(count); } li = review.FindAll(p => (p.Revieweename == reviewDetail.Revieweename && p.Date == reviewDetail.Date)); if (li.Count != 0) { count = -5; return(count); } li = review.FindAll(p => (p.Reviewername == reviewDetail.Revieweename && p.Date == reviewDetail.Date)); if (li.Count != 0) { count = -5; return(count); } employeeContext.Entry(reviewDetail).State = EntityState.Added; count = employeeContext.SaveChanges(); return(count); } }
//Method to check the logix to schedule review details public int CheckLogic(Review_Details reviewDetail) { int count = 0; IList <Review_Details> li = null; List <Review_Details> review = null; using (EmployeeContext employeeContext = new EmployeeContext()) { review = employeeContext.Review_Detail.ToList(); li = review.FindAll(p => (p.Revieweename == reviewDetail.Reviewername && p.Date == reviewDetail.Date)); if (li.Count != 0) { count = -4; return(count); } li = review.FindAll(p => (p.Revieweename == reviewDetail.Revieweename && p.Date == reviewDetail.Date)); if (li.Count != 0) { count = -5; return(count); } li = review.FindAll(p => (p.Reviewername == reviewDetail.Revieweename && p.Date == reviewDetail.Date)); if (li.Count != 0) { count = -5; return(count); } return(count); } }
//Method to update review details public bool UpdateReview(Review_Details reviewDetail) { using (EmployeeContext employeeContext = new EmployeeContext()) { employeeContext.Entry(reviewDetail).State = EntityState.Modified; employeeContext.SaveChanges(); return(true); } }
//Method to delete review details public void Delete(int employeeId) { using (EmployeeContext employeeContext = new EmployeeContext()) { Review_Details reviewDetail = GetReviewDetailsById(employeeId); employeeContext.Entry(reviewDetail).State = EntityState.Deleted; employeeContext.SaveChanges(); //SqlParameter sqlEmployee = new SqlParameter("@Id", employee.Id); //employeeContext.Database.ExecuteSqlCommand("Employee_Delete @Id", sqlEmployee); //SqlParameter sqlAccount = new SqlParameter("@AccountId", accountdetails.AccountId); //employeeContext.Database.ExecuteSqlCommand("AccountDetails_Delete @AccountId", sqlAccount); } }
public ActionResult Index(FormCollection form) { if (ModelState.IsValid) { int revieweeDesignationId = Convert.ToInt32(form["RevieweeDesignationId"]); int reviewerDepartmentId = Convert.ToInt32(form["ReviewerDepartmentId"]); int revieweeDepartmentId = Convert.ToInt32(form["RevieweeDepartmentId"]); string reviewerName = (form["ReviewerName"]).ToString(); int reviewerDesignationId = Convert.ToInt32(form["ReviewerDesignationId"]); string revieweeName = (form["RevieweeName"]).ToString(); DateTime date = Convert.ToDateTime(form["Date"]); Review_Details reviewDetail = new Review_Details(); reviewDetail.Reviewername = reviewerName; reviewDetail.Revieweename = revieweeName; reviewDetail.ReviewerDesignationId = reviewerDesignationId; reviewDetail.ReviewerDepartmentId = reviewerDepartmentId; reviewDetail.RevieweeDesignationId = revieweeDesignationId; reviewDetail.RevieweeDepartmentId = revieweeDepartmentId; reviewDetail.Date = date; if (reviewerName == revieweeName) { TempData["Message"] = "Reviewer and Reviewee should not be same"; return(RedirectToAction("DisplayMessages")); } int count = reviewDetailsBL.Add(reviewDetail); if (count == -5) { TempData["Message"] = "Already a review is scheduled on that day for reviewee"; return(RedirectToAction("DisplayMessages")); } else if (count == -4) { TempData["Message"] = "Already a review is scheduled on that day for reviewer"; return(RedirectToAction("DisplayMessages")); } else if (count != 0) { return(RedirectToAction("DisplayReviewDetails", reviewDetail)); } } return(RedirectToAction("ScheduleReview")); }
public bool UpdateReview(Review_Details reviewDetail) { return(reviewDetailsRepositary.UpdateReview(reviewDetail)); }
public int CheckLogic(Review_Details reviewDetail) { return(reviewDetailsRepositary.CheckLogic(reviewDetail)); }
//public int AddReviewDetails(int reviewerDepartmentId,int reviewerDesignationId, int reviewerName,int revieweeDepartmentId,int revieweeDesignationId, int revieweeName,DateTime date) //{ // return reviewDetailsRepositary.AddReviewDetails(reviewerDepartmentId, reviewerDesignationId, reviewerName, revieweeDepartmentId, revieweeDesignationId, revieweeName,date); //} public int Add(Review_Details reviewDetail) { return(reviewDetailsRepositary.Add(reviewDetail)); }