public ActionResult Create() { //Create Item GSTIdentificationNumber gstIdentificationNumber = new GSTIdentificationNumber(); //AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //CountryList SelectList SelectList countryList = new SelectList(countryRepository.GetCountriesbyRole(groupName).ToList(), "CountryCode", "CountryName"); ViewData["CountryList"] = countryList; //StateProvince SelectList SelectList stateProvinceList = new SelectList(stateProvinceRepository.GetStateProvincesByCountryCode(gstIdentificationNumber.CountryCode).ToList(), "StateProvinceCode", "Name"); ViewData["StateProvinceList"] = stateProvinceList; return(View(gstIdentificationNumber)); }
//Add Data From Linked Tables for Display public void EditForDisplay(GSTIdentificationNumber gstIdentificationNumber) { CountryRepository countryRepository = new CountryRepository(); Country country = new Country(); country = countryRepository.GetCountry(gstIdentificationNumber.CountryCode); if (country != null) { gstIdentificationNumber.CountryName = country.CountryName; } ClientTopUnitRepository clientTopUnitRepository = new ClientTopUnitRepository(); ClientTopUnit clientTopUnit = clientTopUnitRepository.GetClientTopUnit(gstIdentificationNumber.ClientTopUnitGuid); if (clientTopUnit != null) { gstIdentificationNumber.ClientTopUnitName = clientTopUnit.ClientTopUnitName; } StateProvinceRepository stateProvinceRepository = new StateProvinceRepository(); StateProvince stateProvince = stateProvinceRepository.GetStateProvinceByCountry(gstIdentificationNumber.CountryCode, gstIdentificationNumber.StateProvinceCode); if (stateProvince != null) { gstIdentificationNumber.StateProvinceName = stateProvince.Name; } }
public ActionResult Delete(int id) { GSTIdentificationNumberVM gstIdentificationNumberVM = new GSTIdentificationNumberVM(); GSTIdentificationNumber gstIdentificationNumber = new GSTIdentificationNumber(); gstIdentificationNumber = gstIdentificationNumberRepository.GetGSTIdentificationNumber(id); //Check Exists if (gstIdentificationNumber == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } //Check Access Rights to Domain if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } gstIdentificationNumberRepository.EditForDisplay(gstIdentificationNumber); gstIdentificationNumberVM.GSTIdentificationNumber = gstIdentificationNumber; return(View(gstIdentificationNumberVM)); }
//Delete in DB public void Delete(GSTIdentificationNumber gstIdentificationNumber) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; db.spDesktopDataAdmin_DeleteGSTIdentificationNumber_v1( gstIdentificationNumber.GSTIdentificationNumberId, adminUserGuid, gstIdentificationNumber.VersionNumber ); }
// GET: /View public ActionResult ViewItem(int id) { //Check Exists GSTIdentificationNumber gstIdentificationNumber = new GSTIdentificationNumber(); gstIdentificationNumber = gstIdentificationNumberRepository.GetGSTIdentificationNumber(id); if (gstIdentificationNumber == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } gstIdentificationNumberRepository.EditForDisplay(gstIdentificationNumber); return(View(gstIdentificationNumber)); }
public ActionResult Edit(GSTIdentificationNumber gstIdentificationNumber) { //Check Access Rights to Domain if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Update Model from Form try { UpdateModel(gstIdentificationNumber); } catch { string n = ""; foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { n += error.ErrorMessage; } } ViewData["Message"] = "ValidationError : " + n; return(View("Error")); } //Database Update try { gstIdentificationNumberRepository.Update(gstIdentificationNumber); } catch (SqlException ex) { LogRepository logRepository = new LogRepository(); logRepository.LogError(ex.Message); ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details"; return(View("Error")); } return(RedirectToAction("List")); }
public ActionResult Delete(GSTIdentificationNumberVM gstIdentificationNumberVM) { //Get Item GSTIdentificationNumber gstIdentificationNumber = new GSTIdentificationNumber(); gstIdentificationNumber = gstIdentificationNumberRepository.GetGSTIdentificationNumber(gstIdentificationNumberVM.GSTIdentificationNumber.GSTIdentificationNumberId); //Check Exists if (gstIdentificationNumberVM.GSTIdentificationNumber == null) { ViewData["ActionMethod"] = "DeletePost"; return(View("RecordDoesNotExistError")); } //Check Access Rights to Domain if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Delete Item try { gstIdentificationNumberRepository.Delete(gstIdentificationNumber); } catch (SqlException ex) { //Versioning Error - go to standard versionError page if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/GSTIdentificationNumber.mvc/Delete/" + gstIdentificationNumber.GSTIdentificationNumberId.ToString(); return(View("VersionError")); } //Generic Error ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details"; return(View("Error")); } //Return return(RedirectToAction("List")); }
//Add to DB public void Add(GSTIdentificationNumber gstIdentificationNumber) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; db.spDesktopDataAdmin_InsertGSTIdentificationNumber_v1( gstIdentificationNumber.GSTIdentificationNumber1, gstIdentificationNumber.ClientTopUnitGuid, gstIdentificationNumber.ClientEntityName, gstIdentificationNumber.BusinessPhoneNumber, gstIdentificationNumber.BusinessEmailAddress, gstIdentificationNumber.FirstAddressLine, gstIdentificationNumber.SecondAddressLine, gstIdentificationNumber.CityName, gstIdentificationNumber.CountryCode, gstIdentificationNumber.StateProvinceCode, gstIdentificationNumber.PostalCode, adminUserGuid ); }
// GET: /Edit public ActionResult Edit(int id) { //Get Item GSTIdentificationNumber gstIdentificationNumber = new GSTIdentificationNumber(); gstIdentificationNumber = gstIdentificationNumberRepository.GetGSTIdentificationNumber(id); //Check Exists if (gstIdentificationNumber == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } //AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } gstIdentificationNumberRepository.EditForDisplay(gstIdentificationNumber); //CountryList SelectList SelectList countryList = new SelectList(countryRepository.GetCountriesbyRole(groupName).ToList(), "CountryCode", "CountryName", gstIdentificationNumber.CountryCode); ViewData["CountryList"] = countryList; //StateProvince SelectList SelectList stateProvinceList = new SelectList(stateProvinceRepository.GetStateProvincesByCountryCode(gstIdentificationNumber.CountryCode).ToList(), "StateProvinceCode", "Name", gstIdentificationNumber.StateProvinceCode); ViewData["StateProvinceList"] = stateProvinceList; return(View(gstIdentificationNumber)); }
public GSTIdentificationNumberVM(GSTIdentificationNumber gstIdentificationNumber) { GSTIdentificationNumber = gstIdentificationNumber; }