public Reply ListarAnimales([FromBody] SecurityViewModel model) { Reply oR = new Reply(); oR.result = 0; //Verificamos el token if (!Verify(model.token)) { oR.mensaje = "no esta autorizado"; oR.result = 0; return(oR); } try { using (cursomvcapiEntities db = new cursomvcapiEntities()) { List <ListAnimalViewModel> lst = (from d in db.animal where d.idState == 1 select new ListAnimalViewModel { Nombre = d.name, Patas = d.patas }).ToList(); oR.data = lst; oR.result = 1; } } catch (Exception ex) { oR.mensaje = "Error en el servidor "; } return(oR); }
public Reply Get([FromBody] SecurityViewModel model) { Reply oReply = new Reply(); oReply.result = 0; // Método de verificación del token if (!Verify(model.token)) { oReply.message = "No autorizado"; return(oReply); } try { using (Cursomvc_apiEntities DB = new Cursomvc_apiEntities()) { // Para respuesta a petición api List <ListAnimalsViewModel> lst = List(DB); // Implementa metodo de helper, que trae resultado en lista, se le pasa como parametro el contexto oReply.data = lst; oReply.result = 1; oReply.message = "Datos enviados: "; } } catch (Exception ex) { oReply.message = " Ocurrió un error, inténtelo más tarde"; } return(oReply); }
protected virtual SecurityViewModel CreateSecurityViewModel() { var securityViewModel = new SecurityViewModel(Settings.Security, _parentWindow, CurrentEnvironment); securityViewModel.SetItem(securityViewModel); return(securityViewModel); }
// // GET: /Manage/Index public async Task <ActionResult> Security(ManageMessageId?message) { ViewBag.StatusMessage = message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed." : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set." : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set." : message == ManageMessageId.Error ? "An error has occurred." : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added." : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed." : ""; var userId = User.Identity.GetUserId(); var model = new SecurityViewModel { HasPassword = HasPassword(), PhoneNumber = await _userManager.GetPhoneNumberAsync(userId), TwoFactor = await _userManager.GetTwoFactorEnabledAsync(userId), Logins = await _userManager.GetLoginsAsync(userId), BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId) }; return(View(model)); }
public Reply Get([FromBody] SecurityViewModel model) { Reply oR = new Reply(); oR.Result = 0; if (!Verify(model.token)) { oR.Message = "No Autorizado"; return(oR); } try { using (NorthwindDBCon db = new NorthwindDBCon()) { oR.Data = (from d in db.Animals where d.idState == 1 select new ListAnimalsViewModel { Name = d.Name, Patas = d.Patas }).ToList(); oR.Result = 1; } } catch (Exception ex) { oR.Message = "Ocurrio un error con el servidor, por favor intenta mas tarde."; //throw; } return(oR); }
public Reply ListarFacturas([FromBody] SecurityViewModel model) { Reply oR = new Reply(); oR.result = 0; if (!Verify(model.token)) { oR.mensaje = "no esta autorizado"; oR.result = 0; return(oR); } try { using (cursomvcapiEntities db = new cursomvcapiEntities()) { List <ListFacturaViewModel> lstFact = (from d in db.facturas select new ListFacturaViewModel { Id = d.id, NumFactura = d.numfactura, Monto = (decimal)d.monto, Fecha = (DateTime)d.fecha }).ToList(); oR.data = lstFact; oR.result = 1; } } catch (Exception ex) { oR.mensaje = "No se pueden listar las faturass"; } return(oR); }
public IHttpActionResult PostSession(SecurityViewModel obj) { if (con.State == ConnectionState.Open) { con.Close(); } con.Open(); SqlCommand cmd1 = new SqlCommand("SP_SaveSecurityNotification", con); cmd1.CommandType = CommandType.StoredProcedure; cmd1.Parameters.AddWithValue("@UserId", obj.Sm.UserId); cmd1.Parameters.AddWithValue("@SendEmailOnLogin", obj.Sm.SendEmailOnLogin); cmd1.Parameters.AddWithValue("@DetectIpAddressChange", obj.Sm.DetectIP); cmd1.Parameters.AddWithValue("@IpAddressWhiteList", obj.Sm.IPAdressWhiteList); int Result = cmd1.ExecuteNonQuery(); con.Close(); if (Result != 0) { return(Ok("Successfully")); } else { return(BadRequest("Error")); } }
public Reply Get([FromBody] SecurityViewModel model) { Reply oReply = new Reply(); oReply.result = 0; if (!Verify(model.token)) { oReply.message = "Not authorized"; return(oReply); } try { using (var dbContext = new Example002Entities()) { oReply.data = (from a in dbContext.Animals join s in dbContext.States on a.IdState equals s.Id where s.Name.Equals("Active") select new ListAnimalsViewModel { Name = a.Name, Foots = a.Foots }).ToList(); oReply.result = 1; } } catch (Exception exception) { oReply.message = string.Format("There was an error. {0}", exception.Message); } return(oReply); }
public async Task <IActionResult> Security(SecurityViewModel model) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Something went wrong"); return(View(model)); } var user = await _userManager.GetUserAsync(User); if (user == null) { ModelState.AddModelError("", $"Unable to load user with ID '{_userManager.GetUserId(User)}'."); return(View()); } var changePasswordResult = await _userManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword); if (!changePasswordResult.Succeeded) { Errors(changePasswordResult); return(View(model)); } await _signInManager.RefreshSignInAsync(user); return(View(model)); }
public string GetSecurityData() { var adminQueries = DependencyResolver.Current.GetService <IAdminQueries>(); var authQueries = DependencyResolver.Current.GetService <IAuthQueries>(); var admin = adminQueries.GetAdminById(CurrentUser.Id); var viewModel = new SecurityViewModel { UserName = CurrentUser.UserName, Operations = authQueries.GetPermissions().Select(p => new PermissionViewModel { Id = p.Id, Name = p.Name, Module = p.Module }), UserPermissions = authQueries.GetActorPermissions(admin.Id).Select(p => p.Id), Licensees = admin.Licensees.Select(l => l.Id), Permissions = ConstantsHelper.GetConstantsDictionary <Permissions>(), Categories = ConstantsHelper.GetConstantsDictionary <Modules>(), IsSingleBrand = admin.AllowedBrands.Count == 1, IsSuperAdmin = admin.Role.Id == RoleIds.SuperAdminId }; return(SerializeJson(viewModel)); }
public virtual ActionResult Save(PaciViewModel model, string operationNumber) { var newPaciQuestionnaire = model.InstitutionQuestionnaires .SelectMany(p => p.OperationQuestionnaire) .Where(x => x.PaciQuestionnaireId == default(int)) .ToList(); if (!newPaciQuestionnaire.HasAny()) { return(RedirectToAction("Index", new { operationNumber = operationNumber })); } var response = _paciService.SavePaci(new PaciSaveRequest { OperationNumber = operationNumber, OperationQuestionnaire = newPaciQuestionnaire }); if (!response.IsValid) { var security = new SecurityViewModel() { PageName = SecurityAttributes.UIPA001EDIT, Security = GetFieldsSecurity(SecurityAttributes.UIPA001EDIT, operationNumber, IDBContext.Current.Permissions).SecuredFields.ToList() }; model.IsEdit = true; model.Security = security; model.ErrorMessage = response.ErrorMessage; return(View("~/Areas/PACI/Views/Paci/Index.cshtml", model)); } return(RedirectToAction("Index", new { operationNumber = operationNumber })); }
public void Ok() { SecurityViewModel VM = IoC.Get <SecurityViewModel>(); var result = windowManager.ShowDialog(VM); if (result.HasValue && result.Value) { LotsResultList.Clear(); foreach (var item in ResultList) { if (item.IsSel) { LotsResultList.Add(item); } } if (TitleStr == "批量复核") { CheckReultList(VM.LoginID); } else if (TitleStr == "解除复核") { CancelReultList(VM.LoginID); } else if (TitleStr == "批量传输") { SendReultList(VM.LoginID); } } RequestClose(); }
//public async Task<ActionResult> EmailFalse(string userId, bool value) //{ // return RedirectToAction("ChangeEmailStatus", new { userid = userId, value = value }); //} //public PartialViewResult Details() //{ // //sample s = new sample(); // sample s = new sample(); // s.no = 1; // ViewBag.a="Naresh......"; // return PartialView("At"); //} //public ActionResult Demo() //{ // sample s = new sample(); // s.no = 1; // Details(); // return View(s); //} public ActionResult PostSession(SecurityViewModel obj, string [] DynamicTextBox) { if (DynamicTextBox != null) { string id = User.Identity.GetUserId(); string Mac = "Null"; string location = "Null"; foreach (var r in DynamicTextBox) { string Ip = r; if (Ip != "") { ValueController.PostSecurityData(id, Ip, Mac, location, true); } } TempData["success"] = "IP Adress successfully updated....!"; return(RedirectToAction("Security")); } if (!ModelState.IsValid) { try { ViewBag.BTC = "$" + Math.Round(Convert.ToDecimal(objCoin.BTCCurrentPrice()), 2); } catch (Exception ex) { ViewBag.BTC = ex.Message; } try { ViewBag.ETH = "$" + Math.Round(Convert.ToDecimal(objCoin.ETHCurrentPrice()), 2); } catch (Exception ex) { ViewBag.ETH = ex.Message; } try { ViewBag.DASH = "$" + Math.Round(Convert.ToDecimal(objCoin.DASHCurrentPrice()), 2); } catch (Exception ex) { ViewBag.DASH = ex.Message; } try { ViewBag.LTC = "$" + Math.Round(Convert.ToDecimal(objCoin.LTCCurrentPrice()), 2); } catch (Exception ex) { ViewBag.LTC = ex.Message; } try { ViewBag.ETC = "$" + Math.Round(Convert.ToDecimal(objCoin.ETCCurrentPrice()), 2); } catch (Exception ex) { ViewBag.ETC = ex.Message; } try { ViewBag.MBC = "$" + Math.Round(Convert.ToDecimal(objCoin.GetMBC_USDCoin()), 2); } catch (Exception ex) { ViewBag.MBC = ex.Message; } obj.s = Session["EmailStatus"] as sample; return(View("Settings", obj)); } var userId = User.Identity.GetUserId(); obj.Sm.UserId = userId; using (var client = new HttpClient()) { client.BaseAddress = new Uri(url + "Transaction/PostSession"); var postTask = client.PostAsJsonAsync(url + "Transaction/PostSession", obj); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { ModelState.Clear(); TempData["success"] = "Security Session succeccfully updated..."; return(RedirectToAction("Security")); } } ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator."); obj.s = Session["EmailStatus"] as sample; try { ViewBag.BTC = "$" + Math.Round(Convert.ToDecimal(objCoin.BTCCurrentPrice()), 2); } catch (Exception ex) { ViewBag.BTC = ex.Message; } try { ViewBag.ETH = "$" + Math.Round(Convert.ToDecimal(objCoin.ETHCurrentPrice()), 2); } catch (Exception ex) { ViewBag.ETH = ex.Message; } try { ViewBag.DASH = "$" + Math.Round(Convert.ToDecimal(objCoin.DASHCurrentPrice()), 2); } catch (Exception ex) { ViewBag.DASH = ex.Message; } try { ViewBag.LTC = "$" + Math.Round(Convert.ToDecimal(objCoin.LTCCurrentPrice()), 2); } catch (Exception ex) { ViewBag.LTC = ex.Message; } try { ViewBag.ETC = "$" + Math.Round(Convert.ToDecimal(objCoin.ETCCurrentPrice()), 2); } catch (Exception ex) { ViewBag.ETC = ex.Message; } try { ViewBag.MBC = "$" + Math.Round(Convert.ToDecimal(objCoin.GetMBC_USDCoin()), 2); } catch (Exception ex) { ViewBag.MBC = ex.Message; } return(View("Security", obj)); }
public async Task<IActionResult> Security(bool JustHaveUpdated) { var user = await GetCurrentUserAsync(); var model = new SecurityViewModel(user) { JustHaveUpdated = JustHaveUpdated }; return View(model); }
/// <summary> /// Saves the settings. /// </summary> /// <returns></returns> bool SaveSettings() { if (CurrentEnvironment.IsConnected) { if (CurrentEnvironment.AuthorizationService.IsAuthorized(AuthorizationContext.Administrator, null)) { Tracker.TrackEvent(TrackerEventGroup.Settings, TrackerEventName.SaveClicked); // Need to reset sub view models so that selecting something in them fires our OnIsDirtyPropertyChanged() ClearErrors(); if (SecurityViewModel.HasDuplicateResourcePermissions()) { IsSaved = false; IsDirty = true; ShowError(StringResources.SaveSettingErrorPrefix, StringResources.SaveSettingsDuplicateResourcePermissions); return(false); } if (SecurityViewModel.HasDuplicateServerPermissions()) { IsSaved = false; IsDirty = true; ShowError(StringResources.SaveSettingErrorPrefix, StringResources.SaveSettingsDuplicateServerPermissions); return(false); } SecurityViewModel.Save(Settings.Security); if (LogSettingsViewModel.IsDirty) { LogSettingsViewModel.Save(Settings.Logging); } if (PerfmonViewModel.IsDirty) { PerfmonViewModel.Save(Settings.PerfCounters); } var isWritten = WriteSettings(); if (isWritten) { ResetIsDirtyForChildren(); IsSaved = true; IsDirty = false; ClearErrors(); } else { IsSaved = false; IsDirty = true; } return(IsSaved); } ShowError(StringResources.SaveSettingErrorPrefix, StringResources.SaveSettingsPermissionsErrorMsg); return(false); } ShowError(StringResources.SaveSettingErrorPrefix, StringResources.SaveSettingsNotReachableErrorMsg); return(false); }
bool ValidateDuplicateResourcePermissions() { if (SecurityViewModel.HasDuplicateResourcePermissions()) { IsSaved = false; IsDirty = true; ShowError(StringResources.SaveErrorPrefix, StringResources.SaveSettingsDuplicateResourcePermissions); _popupController.ShowHasDuplicateResourcePermissions(); return(false); } return(true); }
/// <summary> /// Saves the settings. /// </summary> /// <returns></returns> bool SaveSettings() { if (CurrentEnvironment.IsConnected) { if (CurrentEnvironment.AuthorizationService.IsAuthorized(AuthorizationContext.Administrator, null)) { // Need to reset sub view models so that selecting something in them fires our OnIsDirtyPropertyChanged() ClearErrors(); if (!ValidateDuplicateResourcePermissions()) { return(false); } if (!ValidateDuplicateServerPermissions()) { return(false); } if (!ValidateResourcePermissions()) { return(false); } SecurityViewModel.Save(Settings.Security); if (!SaveLogSettingsChanges()) { return(false); } if (PerfmonViewModel.IsDirty) { PerfmonViewModel.Save(Settings.PerfCounters); } var isWritten = WriteSettings(); if (isWritten) { ResetIsDirtyForChildren(); IsSaved = true; IsDirty = false; ClearErrors(); } else { IsSaved = false; IsDirty = true; } return(IsSaved); } ShowError(StringResources.SaveErrorPrefix, StringResources.SaveSettingsPermissionsErrorMsg); _popupController.ShowSaveSettingsPermissionsErrorMsg(); return(false); } ShowError(StringResources.SaveErrorPrefix, StringResources.SaveServerNotReachableErrorMsg); _popupController.ShowSaveServerNotReachableErrorMsg(); return(false); }
public async Task <ActionResult> Index() { string userId = User.Identity.GetUserId(); var model = new SecurityViewModel { TwoFactorEnabled = await UserManager.GetTwoFactorEnabledAsync(userId), PhoneNumber = await UserManager.GetPhoneNumberAsync(userId), Logins = await UserManager.GetLoginsAsync(userId), BrowserRemembered = await AuthManager.TwoFactorBrowserRememberedAsync(userId) }; return(View(model)); }
public PropertiesWindow() { InitializeComponent(); var loc = App.Current.FindResource("Locator") as ViewModelLocator; this._genSettings = loc.Settings; this._h264Settins = loc.H264Settings; this._recorderSettings = loc.RecorderSettings; this._metadataSettings = loc.Metadata; this._secureSettings = loc.Security; this.SetSecureData(); }
public IActionResult Security() { SecurityViewModel model = new SecurityViewModel(); string id = getID(); if (id == null) { return(Redirect("/Login/Login")); } Account account = DataBaseAccess.getObject <Account>(new Account(id)); model.password = account.password; return(View(model)); }
public Reply Get(SecurityViewModel model) { Reply oR = new Reply(); oR.Result = 0; if (!Verify(model.Token)) { oR.Message = "No tienes permiso, logueate nuevamente"; return(oR); } try { using (AnimalesContext db = new AnimalesContext()) { var list = (from anim in db.Animalito where anim.IdEstado.Equals(1) select new { id = anim.Id, nombre = anim.Nombre, patas = anim.Patas }).ToList(); if (list.Count > 0) { oR.Data = list; oR.Count = list.Count(); oR.Message = "Se encontraron datos"; oR.Result = 1; } else { oR.Message = "No se encontraron datos"; } } } catch (Exception ex) { oR.Message = "Ha ocurrido un error al traer el listado. " + ex; } return(oR); }
public Reply listaAnimales([FromBody] SecurityViewModel model) { Reply oReply = new Reply(); oReply.result = 0; if (!verificarToken(model.token)) { oReply.message = "usuario no autorizado"; return(oReply); } using (var db = new mvcApiEntities()) { oReply.data = obtenerLista(db); oReply.result = 1; } return(oReply); }
public async Task<IActionResult> Security(SecurityViewModel model) { var cuser = await GetCurrentUserAsync(); if (!ModelState.IsValid) { model.ModelStateValid = false; model.Recover(cuser); return View(model); } var result = await _userService.ChangePasswordAsync(cuser.Id, await _appsContainer.AccessToken(), model.OldPassword, model.NewPassword); if (result.Code == ErrorType.Success) { return RedirectToAction(nameof(Security), new { JustHaveUpdated = true }); } else { ModelState.AddModelError(string.Empty, result.Message); model.ModelStateValid = false; model.Recover(cuser); return View(model); } }
public async Task <IActionResult> Security(SecurityViewModel model) { var currentUser = await GetCurrentUserAsync(); if (!ModelState.IsValid) { model.Recover(currentUser); return(View(model)); } try { await _userService.ChangePasswordAsync(currentUser.Id, await _appsContainer.AccessToken(), model.OldPassword, model.NewPassword); return(RedirectToAction(nameof(Security), new { JustHaveUpdated = true })); } catch (AiurUnexpectedResponse e) { ModelState.AddModelError(string.Empty, e.Message); model.Recover(currentUser); } return(View(model)); }
public async Task <ActionResult> View(int id) { var result = await RestUtility.GetAsync <Security>(string.Format("api/Securities/{0}", id)); if (result == null) { return(new HttpNotFoundResult()); } SecurityViewModel vm = null; switch (result.Code) { case "Fund": vm = new FundViewModel { Id = result.Id, Code = result.Code, Price = result.Price, Symbol = result.Symbol }; break; case "Stock": vm = new StockViewModel { Id = result.Id, Code = result.Code, Price = result.Price, Symbol = result.Symbol }; break; case "Bond": vm = new BondViewModel { Id = result.Id, Code = result.Code, Price = result.Price, Symbol = result.Symbol }; break; default: throw new NotSupportedException(); } return(View(vm)); }
public Reply Get([FromBody] SecurityViewModel model) { Reply oR = new Reply(); oR.result = 0; if (!Verify(model.token)) { oR.message = " No autorizado"; return(oR); } try { using (PruebaEntities db = new PruebaEntities()) { List <ListUsuarioViewModel> lst = (from d in db.Usuario select new ListUsuarioViewModel { nombre = d.nombre, username = d.username }).ToList(); oR.data = lst; oR.result = 1; } } catch (Exception ex) { oR.message = "ocurrio el siguiente error" + ex.ToString(); throw; } return(oR); }
public Reply Get(SecurityViewModel model) { Reply oR = new Reply(); oR.result = 0; try { using (cursomvcapiEntities db = new cursomvcapiEntities()) { List <LstAnimalesViewModel> lst = List(db); oR.data = lst; oR.result = 1; } }catch (Exception ex) { oR.message = "Ocurrio un error en el servidor, intentelo mas tarde"; } return(oR); }
public ViewModelLocator() { try { var config = new ConfigurationBuilder(); config.AddJsonFile("autofac.json"); var module = new ConfigurationModule(config.Build()); var builder = new ContainerBuilder(); builder.RegisterModule(module); Container = builder.Build(); navigationService = Container.Resolve <INavigationService>(); mainWindowViewModel = Container.Resolve <MainWindowViewModel>(); problemsViewModel = Container.Resolve <ProblemsViewModel>(); infrastructureViewModel = Container.Resolve <InfrastructureViewModel>(); buildingViewModel = Container.Resolve <BuildingViewModel>(); governmentViewModel = Container.Resolve <GovernmentViewModel>(); hospitalViewModel = Container.Resolve <HospitalViewModel>(); ideaViewModel = Container.Resolve <IdeaViewModel>(); publicTransportViewModel = Container.Resolve <PublicTransportViewModel>(); roadViewModel = Container.Resolve <RoadViewModel>(); securityViewModel = Container.Resolve <SecurityViewModel>(); tradeAdvertisingViewModel = Container.Resolve <TradeAdvertisingViewModel>(); yardViewModel = Container.Resolve <YardViewModel>(); helloViewModel = Container.Resolve <HelloViewModel>(); importantListViewModel = Container.Resolve <ImportantListViewModel>(); importantInfofViewModel = Container.Resolve <ImportantInfofViewModel>(); newsListViewModel = Container.Resolve <NewsListViewModel>(); newsInfoViewModel = Container.Resolve <NewsInfoViewModel>(); buildingPVModel = Container.Resolve <BuildingPVModel>(); governmentPVModel = Container.Resolve <GovernmentPVModel>(); hospitalPVModel = Container.Resolve <HospitalPVModel>(); ideaPVModel = Container.Resolve <IdeaPVModel>(); infrastructurePVModel = Container.Resolve <InfrastructurePVModel>(); publicTransportPVModel = Container.Resolve <PublicTransportPVModel>(); roadPVModel = Container.Resolve <RoadPVModel>(); securityPVModel = Container.Resolve <SecurityPVModel>(); tradeAdvertisingPVModel = Container.Resolve <TradeAdvertisingPVModel>(); yardPVModel = Container.Resolve <YardPVModel>(); navigationService.Register <ProblemsViewModel>(problemsViewModel); navigationService.Register <InfrastructureViewModel>(infrastructureViewModel); navigationService.Register <BuildingViewModel>(buildingViewModel); navigationService.Register <GovernmentViewModel>(governmentViewModel); navigationService.Register <HospitalViewModel>(hospitalViewModel); navigationService.Register <IdeaViewModel>(ideaViewModel); navigationService.Register <PublicTransportViewModel>(publicTransportViewModel); navigationService.Register <RoadViewModel>(roadViewModel); navigationService.Register <SecurityViewModel>(securityViewModel); navigationService.Register <TradeAdvertisingViewModel>(tradeAdvertisingViewModel); navigationService.Register <YardViewModel>(yardViewModel); navigationService.Register <HelloViewModel>(helloViewModel); navigationService.Register <ImportantListViewModel>(importantListViewModel); navigationService.Register <ImportantInfofViewModel>(importantInfofViewModel); navigationService.Register <NewsListViewModel>(newsListViewModel); navigationService.Register <NewsInfoViewModel>(newsInfoViewModel); navigationService.Register <BuildingPVModel>(buildingPVModel); navigationService.Register <GovernmentPVModel>(governmentPVModel); navigationService.Register <HospitalPVModel>(hospitalPVModel); navigationService.Register <IdeaPVModel>(ideaPVModel); navigationService.Register <InfrastructurePVModel>(infrastructurePVModel); navigationService.Register <PublicTransportPVModel>(publicTransportPVModel); navigationService.Register <RoadPVModel>(roadPVModel); navigationService.Register <SecurityPVModel>(securityPVModel); navigationService.Register <TradeAdvertisingPVModel>(tradeAdvertisingPVModel); navigationService.Register <YardPVModel>(yardPVModel); navigationService.Navigate <HelloViewModel>(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public ActionResult Security(SecurityViewModel obj) { ViewData["message"] = "Lưu thành công!..."; int managerId = obj.managerId; List<TimeTable> lstTimeTable = new List<TimeTable>(); foreach (TimeDayView timeDayView in obj.lstSecurityTimeDay) { foreach (TimeTable item in timeDayView.lstTimeTable) { lstTimeTable.Add(item); } } TimeTableBUS.Update(managerId, lstTimeTable); // Lấy thông tin dữ liệu return View(obj); }
/// <summary> /// Giải thuật: Lưu /// </summary> /// <returns></returns> public ActionResult Security() { // Lấy thông tin StoreManager đăng nhập int storeManagerId = 5; try { // Load tất cả thông tin lên List<TimeDayView> lstTimeDay = new List<TimeDayView>(); for (int i = 0; i < 7; i++) { // Lay thong tin từng ngày TimeDayView newItem = new TimeDayView(); // Lay ra 24giờ trong ngày newItem.dateName = GetDay(i + 1); newItem.lstTimeTable = TimeTableBUS.GetArray(GetDay(i + 1), storeManagerId); if (newItem.lstTimeTable.Count != 24) { throw (new Exception()); } lstTimeDay.Add(newItem); } foreach (TimeDayView dayItem in lstTimeDay) { dayItem.lstTimeTable.Sort( delegate(TimeTable itemTable01, TimeTable timeTable02) { return Comparer<int>.Default.Compare (itemTable01.TimeItem.Hour, timeTable02.TimeItem.Hour); } ); } var model = new SecurityViewModel() { managerId = storeManagerId, storeManagerName = StoreManagerBUS.GetItem(storeManagerId).Name, lstSecurityTimeDay = lstTimeDay }; return View(model); } catch(Exception ex) { /// -------------------------------------------- /// Chi goi khi chua co du lieu, tránh lỗi do /// chưa có dữ liệu TimeItemBUS.AddIfNotExists(storeManagerId); ViewData["message"] = "Lỗi: " + ex.Message; return RedirectToAction("Index", "Store"); /// -------------------------------------------- } }
public MainWindow() { InitializeComponent(); SecurityViewModel vm = new SecurityViewModel(); DataContext = vm; }
public ShellViewModel(GeneralViewModel generalViewModel, DetailsViewModel detailsViewModel, SecurityViewModel securityViewModel) { General = generalViewModel; Details = detailsViewModel; Security = securityViewModel; }