public ActionResult Edit(int id) { if (!_permissionService.Authorize("ManageCaste")) { return(AccessDeniedView()); } if (id == 0) { throw new ArgumentNullException("id"); } var model = new CasteModel(); var objCaste = _smsService.GetCasteById(id); if (objCaste != null) { model = objCaste.ToModel(); } model.AvailableAcadmicYears = _smsService.GetAllAcadmicYears().Select(x => new SelectListItem() { Text = x.Name.Trim(), Value = x.Id.ToString(), Selected = model.AcadmicYearId == x.Id }).ToList(); model.AvailableReligions = _smsService.GetAllReligions().Select(x => new SelectListItem() { Text = x.Name.Trim(), Value = x.Id.ToString(), Selected = model.ReligionId > 0 && model.ReligionId == x.Id }).OrderBy(x => x.Text).ToList(); return(View(model)); }
public void UpdateCaste(CasteModel model) { using (IDbConnection connection = new NpgsqlConnection(GlobalConfig.getDatabaseConnectionString())) { connection.ExecuteScalar($"update caste set caste_id = '{model.caste_id}', caste_name = '{model.caste_name}'"); } }
public CasteModel CreateCaste(CasteModel model) { using (IDbConnection connection = new NpgsqlConnection(GlobalConfig.getDatabaseConnectionString())) { int id = connection.ExecuteScalar <int>($"insert into caste values(default,'{model.caste_id}','{model.caste_name}')"); return(model); } }
public ActionResult List() { if (!_permissionService.Authorize("ManageCaste")) { return(AccessDeniedView()); } var model = new CasteModel(); return(View(model)); }
public ActionResult Edit(CasteModel model, FormCollection frm, bool continueEditing) { if (!_permissionService.Authorize("ManageCaste")) { return(AccessDeniedView()); } var user = _userContext.CurrentUser; // Check for duplicate classroom, if any var checkCaste = _smsService.CheckCasteExists(model.Name, model.Id); if (checkCaste) { ModelState.AddModelError("Name", "A Caste with the same name already exists. Please choose a different name."); } if (ModelState.IsValid) { var objCaste = _smsService.GetCasteById(model.Id); if (objCaste != null) { model.CreatedOn = objCaste.CreatedOn; objCaste = model.ToEntity(objCaste); objCaste.ModifiedOn = DateTime.Now; _smsService.UpdateCaste(objCaste); } } else { model.AvailableAcadmicYears = _smsService.GetAllAcadmicYears().Select(x => new SelectListItem() { Text = x.Name.Trim(), Value = x.Id.ToString(), Selected = model.AcadmicYearId == x.Id }).ToList(); model.AvailableReligions = _smsService.GetAllReligions().Select(x => new SelectListItem() { Text = x.Name.Trim(), Value = x.Id.ToString(), Selected = model.ReligionId > 0 && model.ReligionId == x.Id }).OrderBy(x => x.Text).ToList(); return(View(model)); } SuccessNotification("Caste updated successfully."); if (continueEditing) { return(RedirectToAction("Edit", new { id = model.Id })); } return(RedirectToAction("List")); }
public ActionResult Create() { if (!_permissionService.Authorize("ManageCaste")) { return(AccessDeniedView()); } var model = new CasteModel(); model.AvailableAcadmicYears = _smsService.GetAllAcadmicYears().Select(x => new SelectListItem() { Text = x.Name.Trim(), Value = x.Id.ToString(), Selected = x.IsActive }).ToList(); model.AvailableReligions = _smsService.GetAllReligions().Select(x => new SelectListItem() { Text = x.Name.Trim(), Value = x.Id.ToString() }).OrderBy(x => x.Text).ToList(); return(View(model)); }
private void WireUpForm() { //First, Middle and Last Name model.applicantModel.applicant_firstname = FirstNameTextBox.Text; if (MiddleNameTextBox.Text.Length != 0) { model.applicantModel.applicant_middlename = MiddleNameTextBox.Text; } else { model.applicantModel.applicant_middlename = ""; } model.applicantModel.applicant_lastname = LastNameTextBox.Text; //Get Aquaintance AcquaintanceModel temp = (AcquaintanceModel)AcquaintanceComboBox.SelectedItem; model.applicantModel.applicant_acquaintanceid = temp.acquaintance_id; model.applicantModel.applicant_acquaintancename = AcquaintanceNameTextBox.Text; /* * DOB - DatePicker * Age - AgeTextBlock * Marital Status - MaritalStatusComboBox * Caste - CasteComboBox * Category - CategoryComboBox * State - StateComboBox * District - DistrictComboBox * Pincode - PincodeTextBox * Address - AddressTextBlock * Mobile Number - MobileNumberTextBox * Office Number - OfficeNumberTextBox * Designation - DesignationTextBox * Education - EducationComboBox * Employer Name - EmployerNameTextBox * Office Address - OfficeAddressTextBlock * Distance To NE - DistanceToNeTextBox * Nearest Branch - NearestBranchComboBox */ model.applicantModel.applicant_dob = DatePicker.SelectedDate.ToString().Split(' ').First(); //Marital Status MarriedStatusModel marriedStatusModel = (MarriedStatusModel)MaritalStatusComboBox.SelectedItem; model.applicantModel.applicant_maritalstatusid = marriedStatusModel.maritalstatus_id; //Caste CasteModel casteModel = (CasteModel)CasteComboBox.SelectedItem; model.applicantModel.applicant_casteid = casteModel.caste_id; //Category CategoryModel category = (CategoryModel)CategoryComboBox.SelectedItem; model.applicantModel.applicant_categoryid = category.category_id; //State model.applicantModel.applicant_state = (string)StateComboBox.SelectedItem; //District model.applicantModel.applicant_district = (string)DistrictComboBox.SelectedItem; //Pincode model.applicantModel.applicant_pincode = PincodeTextBox.Text; //Address model.applicantModel.applicant_currentaddress = AddressTextBlock.Text; //Mobile Number model.applicantModel.applicant_mobile = MobileNumberTextBox.Text; //Office Number model.applicantModel.applicant_officeno = OfficeNumberTextBox.Text; //Designation model.applicantModel.applicant_desgination = DesignationTextBox.Text; //Education model.applicantModel.applicant_education = (string)EducationComboBox.SelectedItem; //Employer Name model.applicantModel.applicant_employername = EmployerNameTextBox.Text; //Office Address model.applicantModel.applicant_officeaddress = OfficeAddressTextBlock.Text; //Distance to NE model.applicantModel.applicant_distance = int.Parse(DistanceToNeTextBox.Text); //Nearest Branch model.applicantModel.applicant_nearestbranch = (string)NearestBranchComboBox.SelectedItem; }
public static Caste ToEntity(this CasteModel model, Caste destination) { return(model.MapTo(destination)); }
public static Caste ToEntity(this CasteModel model) { return(model.MapTo <CasteModel, Caste>()); }