public IHttpActionResult SubmitRatingByDtlPostId(RatingParam param) { string message = string.Empty; using (var repository = new PostingRepository(param.UserId)) { var result = repository.SubmitRatingByDtlPostId(param.DtlPostingId, param.UserId, param.Rating, param.RatingComment, param.IsRate, param.CreatedBy); if (!result.Response) { log.Info("Bidding Rating operation is fail"); } return(Ok(new { result.Status, data = result })); } }
public object MarkRating(RatingParam obj) { try { RatingBusiness objp = new RatingBusiness(); var Rate = objp.AddMark(obj); return(Rate); } catch (Exception e) { return(new Error() { IsError = true, Message = e.Message }); } }
public object AddMark(RatingParam obj) { try { SchoolMainContext db = new ConcreateContext().GetContext(obj.UserName, obj.Password); var Info = db.TBLUSERLOGINs.Where(r => r.UserName == obj.UserName && r.Password == obj.Password).FirstOrDefault(); if (db == null) { return(new Results() { IsSuccess = false, Message = "Invalid User" }); } if (Info == null) { return(new Results() { IsSuccess = false, Message = "Invalid User" }); } var AcademicYear = db.View_GETACADEMICYEAR.FirstOrDefault(); if (AcademicYear == null) { return(new Results() { IsSuccess = false, Message = "Academic Year Not Found" }); } var EmployeeCode = Convert.ToInt16(Info.EmpCode); var StudentDetails = db.TBLTRANSFERSTUDENTs.Where(r => r.STUDENTID == EmployeeCode && r.ACADEMICYEAR == AcademicYear.ACADEMICYEAR).FirstOrDefault(); int STNDARDID = Convert.ToInt32(StudentDetails.STANDARDID); int DIVISIONID = Convert.ToInt32(StudentDetails.DIVISIONID); var AssignTeacher = db.TBLASSIGNSTAFFs.Where(r => r.EMPLOYEEID == obj.TeacherId && r.STNDARDID == STNDARDID && r.DIVISIONID == DIVISIONID).ToList(); if (AssignTeacher.Count == 0) { return(new Results() { IsSuccess = false, Message = "Teacher Not Assign" }); } TBLRATINGDETAIL tblobj = new TBLRATINGDETAIL(); if (obj.Mark >= 10) { return(new Results() { IsSuccess = false, Message = "Mark is less than 10" }); } var DuplicateEntry = db.TBLRATINGDETAILS.Where(r => r.StudentId == EmployeeCode && r.TeacherId == obj.TeacherId && r.RatingMasterId == obj.RatingMasterId).FirstOrDefault(); if (DuplicateEntry != null) { return(new Results() { IsSuccess = false, Message = "You have already rated this Subject" }); } // tblobj.RatingMasterId= tblobj.TeacherId = obj.TeacherId; tblobj.RatingMasterId = obj.RatingMasterId; tblobj.StudentId = EmployeeCode; tblobj.Mark = obj.Mark; tblobj.AcademicYear = AcademicYear.ACADEMICYEAR; tblobj.CreatedId = EmployeeCode; tblobj.CreatedOn = System.DateTime.Today.Date; tblobj.Display = 1; db.TBLRATINGDETAILS.Add(tblobj); db.SaveChanges(); return(new Results() { IsSuccess = true, Message = "Rating Sucessfully" }); } catch (Exception ex) { return(new Results { IsSuccess = false, Message = ex.Message }); } }