public async Task <IActionResult> InsertPromotion(IndexStudentPromotionsVM obj) { try { ViewBag.ddlClass = _classesServ.dropdown_Class(); if (obj.StudentPromotions != null) { var StudentPromotions = new InsertStudentPromotions_StudentPromotions() { StudentId = obj.StudentPromotions.StudentId, ClassId = obj.StudentPromotions.ClassId, RollNo = obj.StudentPromotions.RollNo, Year = obj.StudentPromotions.Year, IsActive = obj.StudentPromotions.IsActive, AddedBy = 0, AddedDate = DateTime.Now, ModifiedBy = 0, ModifiedDate = DateTime.Now, DataType = null }; var model = new InsertStudentPromotions() { StudentPromotions = StudentPromotions }; await Task.Run(() => _StudentPromotionsServ.InsertStudentPromotions(model)); } } catch (Exception) { return(BadRequest()); } return(RedirectToAction("StudentPromotionsList")); }
public string InsertStudentPromotions(InsertStudentPromotions obj) { string returnResult = (dynamic)null; try { if (obj != null) { var ClassYear = DateTime.ParseExact(obj.StudentPromotions.Year, "yyyy", null); //[Note: insert 'states' table] if (obj.StudentPromotions != null) { var StudentPromotions = new InsertStudentPromotions_StudentPromotions() { StudentId = obj.StudentPromotions.StudentId, ClassId = obj.StudentPromotions.ClassId, RollNo = obj.StudentPromotions.RollNo, ClassYear = ClassYear, IsActive = obj.StudentPromotions.IsActive, AddedBy = 0, AddedDate = DateTime.Now, ModifiedBy = 0, ModifiedDate = DateTime.Now, DataType = null }; _StudentPromotionsRepo.Insert(StudentPromotions); returnResult = "Saved"; } } } catch (Exception ex) { returnResult = "ERROR102:PromotionClassesServ/InsertPromotionList - " + ex.Message; } return(returnResult); }