private void RepopulateListsFromCacheSession(SiteVM model) { // Populate cached lists if they are empty. model.NominatedManagerSearchList = sessionManager.SiteNominatedManagersSearch; model.DeputyNominatedManagerSearchList = sessionManager.SiteDeputyNominatedManagersSearch; model.DeputyNominatedManagerList = sessionManager.SiteDeputyNominatedManagers; }
/// <summary> /// Private method to merge in the model /// </summary> /// <returns></returns> private SiteVM GetUpdatedModel() { SiteVM model = new SiteVM(); RepopulateListsFromCacheSession(model); model.Message = ""; if (sessionManager.CurrentSite != null) { model.SiteItem = sessionManager.CurrentSite; } //***************************************NEED WHITE LIST ---- BLACK LIST ------ TO PREVENT OVERPOSTING ************************** bool result = TryUpdateModel(model);//This also validates and sets ModelState //******************************************************************************************************************************* if (sessionManager.CurrentSite != null) { //*****************************************PREVENT OVER POSTING ATTACKS****************************************************** //Get the values for read only fields from session MergeNewValuesWithOriginal(model.SiteItem); //*************************************************************************************************************************** } DetermineIsDirty(model); SetAccessContext(model); return(model); }
public JsonResult Add([FromBody] SiteVM model) { var site = Mapper.Map <Site>(model); _siteService.Add(site); _siteService.SaveChanges(); return(Json(_siteService.Get(site.Id))); }
public bool Insert(SiteVM SiteVM) { var push = new Site(SiteVM); applicationContext.Sites.Add(push); var result = applicationContext.SaveChanges(); return(result > 0); }
public bool Update(int id, SiteVM SiteVM) { var get = Get(id); get.Update(SiteVM); applicationContext.Entry(get).State = EntityState.Modified; var result = applicationContext.SaveChanges(); return(result > 0); }
private void SetFlagsFalse(SiteVM model) { model.IsDeleteConfirmed = "False"; model.IsExitConfirmed = "False"; model.IsNewConfirmed = "False"; //Stop the binder resetting the posted values ModelState.Remove("IsDeleteConfirmed"); ModelState.Remove("IsExitConfirmed"); ModelState.Remove("IsNewConfirmed"); }
public HttpResponseMessage InsertSite(SiteVM siteVM) { var message = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Wrong Parameter"); var result = _iSiteService.Insert(siteVM); if (result) { message = Request.CreateResponse(HttpStatusCode.OK, "Successfully Added"); } return(message); }
private void DetermineIsDirty(SiteVM model) { //Compare the Site to the original session if (model.SiteItem.PublicInstancePropertiesEqual(sessionManager.SiteServiceVersion, "RowIdentifier")) { model.IsViewDirty = false; } else { model.IsViewDirty = true; } }
public bool Update(int id, SiteVM siteVM) { if (string.IsNullOrWhiteSpace(id.ToString()) || string.IsNullOrWhiteSpace(siteVM.Name) || string.IsNullOrWhiteSpace(siteVM.Address)) { return(status); } else { var result = _siteRepository.Update(id, siteVM); return(result); } }
public bool Insert(SiteVM siteVM) { if (string.IsNullOrWhiteSpace(siteVM.Name) || string.IsNullOrWhiteSpace(siteVM.Address)) { return(status); } else { var result = _siteRepository.Insert(siteVM); return(result); } }
private void SetAccessContext(SiteVM model) { //Decide on access context if (null == model.SiteItem || model.SiteItem.Code == Guid.Empty) { // Create context model.AccessContext = SiteAccessContext.Create; } else { // Edit context model.AccessContext = SiteAccessContext.Edit; } }
public ActionResult ActiveReport() { var model = new ActiveReportVM(); var sites = SitesManager.GetSites(); foreach (var site in sites) { var siteVm = new SiteVM { Id = site.Id, Name = site.Name, ProcessCsv = false }; model.sites.Add(siteVm); } return(View(model)); }
public ActionResult Edit() { // Retrieve ID from session string organisationCode = sessionManager.IsExpected(sessionManager.OrganisationCode); SiteVM model = null; // Create service instance IUcbService sc = UcbService; try { // Call service to get Site item and any associated lookups via Organisation code SiteVMDC returnedObject = sc.GetSiteByOrganisationCode(CurrentUser, CurrentUser, appID, "", organisationCode); // Close service communication ((ICommunicationObject)sc).Close(); //Get view model from service model = ConvertSiteDC(returnedObject); ResolveFieldCodesToFieldNamesUsingLists(model); // Store the service version sessionManager.SiteServiceVersion = model.SiteItem; } catch (Exception e) { // Handle the exception string message = ExceptionManager.HandleException(e, (ICommunicationObject)sc); model.Message = message; return(View(model)); } //Adds current retrieved Site to session sessionManager.CurrentSite = model.SiteItem; sessionManager.SiteNominatedManagersSearch = model.NominatedManagerSearchList; sessionManager.SiteDeputyNominatedManagersSearch = model.DeputyNominatedManagerSearchList; sessionManager.SiteDeputyNominatedManagers = model.DeputyNominatedManagerList; SetAccessContext(model); return(View(model)); }
public HttpResponseMessage UpdateSite(int id, SiteVM siteVM) { var message = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Bad Request"); if (string.IsNullOrWhiteSpace(id.ToString())) { message = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid Id"); } else { var get = _iSiteService.Update(id, siteVM); if (get) { message = Request.CreateResponse(HttpStatusCode.OK, get); return(message); } } return(message); }
private SiteVM ConvertSiteDC(SiteVMDC returnedObject) { SiteVM model = new SiteVM(); // Map Site Item model.SiteItem = Mapper.Map <SiteDC, SiteModel>(returnedObject.SiteItem); // Set Nominated Manager model.NominatedManagerCode = returnedObject.NominatedManagerCode; // Map lookup data lists if (null != returnedObject.NominatedManagerSearchList) { model.NominatedManagerSearchList = Mapper.Map <List <StaffModel> >(returnedObject.NominatedManagerSearchList); } else { model.NominatedManagerSearchList = new List <StaffModel>(); } if (null != returnedObject.DeputyNominatedManagerList) { model.DeputyNominatedManagerList = Mapper.Map <List <StaffModel> >(returnedObject.DeputyNominatedManagerList); } else { model.DeputyNominatedManagerList = new List <StaffModel>(); } if (null != returnedObject.DeputyNominatedManagerSearchList) { model.DeputyNominatedManagerSearchList = Mapper.Map <List <StaffModel> >(returnedObject.DeputyNominatedManagerSearchList); } else { model.DeputyNominatedManagerSearchList = new List <StaffModel>(); } return(model); }
public PageSelection(Window mainView) { InitializeComponent(); if (mainView is PageAjoutIndispo) { _mainView = (PageAjoutIndispo)mainView; } else if (mainView is PageModification) { _mainView = (PageModification)mainView; } List <SecteurVM> secteurs = DataBase.GetsAllSecteursBDD(); ViewModel = new SiteVM(secteurs); this.Fenetre.DataContext = ViewModel; CBcheckall.IsChecked = true; _listeDesMachines = initMachines(); CBcheckall.IsChecked = false; }
private void ResolveFieldCodesToFieldNamesUsingLists(SiteVM model) { //TODO: }
public void Update(SiteVM siteVM) { this.Name = siteVM.Name; this.Address = siteVM.Address; this.UpdateDate = DateTimeOffset.Now.LocalDateTime; }