public bool Update(EvaluationToCLOMapping EvaluationtToCLOMapping) { int status = 0; using (connection = Database.GetConnection()) { try { using (command = new MySqlCommand(Procedures.UpdateEvaluationtToCLOMapping, connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new MySqlParameter("@Id", EvaluationtToCLOMapping.Id)); SetAllParameters(EvaluationtToCLOMapping); connection.Open(); status = command.ExecuteNonQuery(); } } catch (Exception ex) { Logger.Log(ex); } } return((status > 0) ? true : false); }
public string Save(EvaluationToCLOMapping EvaluationToCLOMapping, string CurrentUsername) { string message = IsValidator(EvaluationToCLOMapping, CurrentUsername); if (FindById(EvaluationToCLOMapping.Id, CurrentUsername) == null) { if (string.IsNullOrEmpty(message)) { EvaluationToCLOMapping = SetValues(EvaluationToCLOMapping, CurrentUsername); if (!IsExist(EvaluationToCLOMapping, CurrentUsername)) { EvaluationToCLOMapping.EntryInformation = new EntryInformation() { EntryById = Authorization.GetCurrentUser(CurrentUsername).Id, EntryDate = DateTime.Now }; return(EvaluationToCLOMappingRepository.Save(EvaluationToCLOMapping) ? null : Messages.IssueInDatabase); } else { return(Messages.Exist); } } else { return(message); } } else { return(Messages.Exist); } }
private EvaluationToCLOMapping SetValues(EvaluationToCLOMapping evaluationToCLOMapping, string currentUsername) { evaluationToCLOMapping.AcademicEvaluation = AcademicEvaluationService.FindById(evaluationToCLOMapping.AcademicEvaluation.Id, currentUsername); evaluationToCLOMapping.CLO = CLOService.FindById(evaluationToCLOMapping.CLO.Id, currentUsername); return(evaluationToCLOMapping); }
public string Update(EvaluationToCLOMapping EvaluationToCLOMapping, string CurrentUsername) { EvaluationToCLOMapping FoundedEvaluationToCLOMapping = FindById(EvaluationToCLOMapping.Id, CurrentUsername); EvaluationToCLOMapping.EntryInformation = FoundedEvaluationToCLOMapping.EntryInformation; string message = IsValidator(EvaluationToCLOMapping, CurrentUsername); if (FoundedEvaluationToCLOMapping != null) { if (string.IsNullOrEmpty(message)) { EvaluationToCLOMapping = SetValues(EvaluationToCLOMapping, CurrentUsername); if (!IsExistUpdate(EvaluationToCLOMapping, CurrentUsername)) { return(EvaluationToCLOMappingRepository.Update(EvaluationToCLOMapping) ? null : Messages.IssueInDatabase); } else { return(Messages.NotFound); } } else { return(message); } } else { return(Messages.Exist); } }
private void SetAllParameters(EvaluationToCLOMapping EvaluationtToCLOMapping) { command.Parameters.Add(new MySqlParameter("@CLOId", EvaluationtToCLOMapping.CLO.Id)); command.Parameters.Add(new MySqlParameter("@Points", EvaluationtToCLOMapping.Points)); command.Parameters.Add(new MySqlParameter("@EntryDate", EvaluationtToCLOMapping.EntryInformation.EntryDate)); command.Parameters.Add(new MySqlParameter("@EntryById", EvaluationtToCLOMapping.EntryInformation.EntryById)); command.Parameters.Add(new MySqlParameter("@AcademicEvaluationId", EvaluationtToCLOMapping.AcademicEvaluation.Id)); }
public ActionResult EditEvaluationToCLOMapping(int id) { if (id > 0) { EvaluationToCLOMapping EvaluationToCLOMapping = EvaluationToCLOMappingService.FindById(id, User.Identity.Name); return(View(EvaluationToCLOMapping)); } return(View()); }
///---------------------------------EVALUATION TO CLO MAPPING----------------------------------------/// public ActionResult EvaluationToCLODetails(int id) { if (id > 0) { EvaluationToCLOMapping EvaluationToCLOMapping = EvaluationToCLOMappingService.FindById(id, User.Identity.Name); return(PartialView("Partial/EvaluationToCLODetails", EvaluationToCLOMapping)); } return(View()); }
public string Delete(int Id, string CurrentUsername) { EvaluationToCLOMapping EvaluationToCLOMapping = FindById(Id, CurrentUsername); if (EvaluationToCLOMapping != null) { return(EvaluationToCLOMappingRepository.Delete(Id) ? null : Messages.IssueInDatabase); } else { return(Messages.NotFound); } }
public List <EvaluationToCLOMapping> FindAll() { List <EvaluationToCLOMapping> allEvaluationtToCLOMapping = new List <EvaluationToCLOMapping>(); try { using (connection = Database.GetConnection()) { using (command = new MySqlCommand(Views.ALLEvaluationtToCLOMapping, connection)) { command.CommandType = CommandType.Text; connection.Open(); using (reader = command.ExecuteReader()) { while (reader.Read()) { EvaluationToCLOMapping EvaluationtToCLOMapping = new EvaluationToCLOMapping { Id = reader.GetInt32("id"), AcademicEvaluation = new AcademicEvaluation() { Id = reader.GetInt32("academicevaluation_id") }, CLO = new CLO() { Id = reader.GetInt32("clo_id") }, Points = reader.GetFloat("points"), EntryInformation = new EntryInformation() { EntryById = reader.GetInt32("EntryBy_id"), EntryDate = reader.GetDateTime("EntryDate") } }; allEvaluationtToCLOMapping.Add(EvaluationtToCLOMapping); } } } } } catch (Exception ex) { Logger.Log(ex); } return(allEvaluationtToCLOMapping); }
private bool IsExist(EvaluationToCLOMapping evaluationToCLOMapping, string currentUsername) { List <EvaluationToCLOMapping> EvaluationToCLOMappingLists = FindAll(currentUsername); if (evaluationToCLOMapping != null) { EvaluationToCLOMappingLists = EvaluationToCLOMappingLists .FindAll(em => em.AcademicEvaluation.Id == evaluationToCLOMapping.AcademicEvaluation.Id && em.AcademicEvaluation.SemesterId == evaluationToCLOMapping.AcademicEvaluation.SemesterId && em.CLO.Id == evaluationToCLOMapping.CLO.Id ); return((EvaluationToCLOMappingLists.Count > 0) ? true : false); } else { return(false); } }
private string IsValidator(EvaluationToCLOMapping EvaluationToCLOMapping, string CurrentUsername) { if (FindEvaluation(EvaluationToCLOMapping.AcademicEvaluation.Id, CurrentUsername) != null) { if (FindCLO(EvaluationToCLOMapping.CLO.Id, CurrentUsername) != null) { return(null); } else { return(Messages.CLONotFound); } } else { return(Messages.AssessmentNotFound); } }
public ActionResult CreateEvaluationToCLOMapping(EvaluationToCLOMapping EvaluationToCLOMapping) { if (ModelState.IsValid) { string message = EvaluationToCLOMappingService.Save(EvaluationToCLOMapping, User.Identity.Name); if (string.IsNullOrEmpty(message)) { TempData["Success"] = Messages.Created; return(RedirectToAction("Index")); } else { ViewData["Warning"] = message; } } else { ViewData["Error"] = Messages.InvalidField; } return(View()); }
public EvaluationToCLOMapping FindById(int id, string CurrentUsername) { EvaluationToCLOMapping FoundedEvaluationToCLOMapping = FindAll(CurrentUsername).Find(EvaluationToCLOMapping => EvaluationToCLOMapping.Id == id); return(FoundedEvaluationToCLOMapping); }