public async Task <IActionResult> Edit(int id, PlanViewModel view) { if (id != view.ID) { return(NotFound()); } if (ModelState.IsValid) { try { Plan plan = this.ToPlan(view); context.Update(plan); await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlanExists(view.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Details), new { id })); } FillData(ref view); return(View(view)); }
public ActionResult PlanDePago() { PlanViewModel model = new PlanViewModel(); model.valor = null; model.cuotaInicial = null; model.Tasa = null; model.TEA = 0; model.TCEA = 0; model.idUser = 1; model.VAN = 0; model.Detalle = null; model.carro = null; model.pgT = null; model.pgP = null; using (var db = new FinanzasEntities()) { List <compraInteligente> listado = db.compraInteligente.Where(x => x.user.id.Equals(UserF.id)).OrderByDescending(x => x.id).ToList(); model.Planes = listado; ViewBag.vehiculoId = new SelectList(db.vehiculo.ToList(), "id", "modelo"); ViewData["id"] = UserF.name; return(View(model)); } }
public ActionResult Update(PlanViewModel plan) { WSRequest request = new WSRequest("/plans/" + plan.IdPlan); request.AddAuthorization(Session["token"].ToString()); IEnumerable <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("name", plan.Name), new KeyValuePair <string, string>("left", plan.Left.ToString()), new KeyValuePair <string, string>("price_cents", plan.Price_cents.ToString()), new KeyValuePair <string, string>("rewards", plan.Rewards), }; request.AddJsonParameter(parameters); var response = request.Put(); if (response.Code != 204) { return(RedirectToAction("Edit", "Plan", plan)); } return(RedirectToAction("Show", "Plan", new { idPlan = plan.IdPlan, message = string.Format("O plano {0} - {1} foi atualizado", plan.IdPlan, plan.Name) })); }
/// <summary> /// Saves the measures details. /// </summary> /// <param name="measures">The measures.</param> /// <param name="saveSimulation">if set to <c>true</c> [save simulation].</param> /// <returns>returns string</returns> /// <exception cref="Exception">No Plan Found</exception> public string SaveMeasuresDetails(PlanViewModel measures, bool saveSimulation) { UserModel user = this.GetUserDetails(measures.UserId); if (user.CurentPlan == null) { return("No Plan Found"); } measures.PlanId = user.CurentPlan.Id; if (saveSimulation && user != null) { List <PlanViewModel> simulationList = this.GetSimulations(user); if (simulationList.Count > Constants.SimulationCodes.SimulationsCount) { return(Constants.SimulationCodes.SimulationsMaximumCountReached); } else if (simulationList.Select(x => x.SimulationName.ToLower()).Equals(measures.SimulationName.ToLower())) { return(Constants.SimulationCodes.SimulationsNameAlreadyExists); } } this.syngentaSIPUnitOfWork.UserRepository.SaveMeasuresDetails(measures, saveSimulation); return(Constants.Success); }
public static PlanSaveModel Convert(PlanViewModel model) { return(new PlanSaveModel() { Days = model.Days.Select(x => PlanDaySaveModel.Convert(x)).ToList() }); }
public ActionResult Edit(int idPlan) { WSRequest request = new WSRequest("plans/" + idPlan); request.AddAuthorization(Session["token"].ToString()); var response = request.Get(); if (response.Code != 200) { ModelState.AddModelError("", "Não foi possível buscar esse plano"); return(RedirectToAction("Index", "Plan")); } var body = response.Body; var model = new PlanViewModel { IdPlan = (int)body["id_plan"], Name = body["name"].ToString(), Left = (int)body["left"], Price_cents = (int)body["price_cents"], Rewards = body["rewards"].ToString(), }; return(View(model)); }
// GET: Plans/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var plan = _db.Plan.Find(id); if (plan == null) { return(HttpNotFound()); } var przedmioty = _db.Przedmiot.Where(p => p.PlanId == id).ToList(); var godziny = _db.Godzina.Where(g => g.PlanId == id).OrderBy(g => g.Godzina1).ToList(); var dni = _db.Dzien.Select(d => d.DzienTygodnia).ToList(); PlanViewModel viewModel = new PlanViewModel(przedmioty, godziny, dni); if (przedmioty.Count > 0) { viewModel.Nazwa = przedmioty[0].Plan.Nazwa; } viewModel.Id = id.Value; return(View(viewModel)); }
public PlanManager() { InitializeComponent(); da = new DataAccess(); AvailableFrameModels = da.GetModels(); AvailableBodyModels = da.GetModels(); FramePlans = da.GetPlans(Model.Type.FRAME); BodyPlans = da.GetPlans(Model.Type.BODY); FrameViewModels = new ObservableCollection <PlanViewModel>(); BodyViewModels = new ObservableCollection <PlanViewModel>(); UsedFrameModels = new ObservableCollection <Model>(); UsedBodyModels = new ObservableCollection <Model>(); updateAvailableModels(); foreach (Plan p in FramePlans) { PlanViewModel pvm = new PlanViewModel(p, UsedFrameModels); addPlanViews(pvm); } foreach (Plan p in BodyPlans) { PlanViewModel pvm = new PlanViewModel(p, UsedBodyModels); addPlanViews(pvm); } }
/// <summary> /// Gets the measures. /// </summary> /// <param name="user">The user.</param> /// <returns> /// returns plans /// </returns> public PlanViewModel GetMeasures(UserModel user) { PlanViewModel planViewModel = new PlanViewModel(); if (user.CurentPlan == null) { return(planViewModel); } bool isSalaryDetailsExists = true; if (user.Country.IsSalaryEditable && user.SalaryDetails.Count == 0) { isSalaryDetailsExists = false; } var salariesByQuarter = user.GetSalariesByQuarter(user.CurentPlan.Year, isSalaryDetailsExists); var usertarget = this.syngentaSIPUnitOfWork.UserRepository.GetUserTargetsByUserIdPlanId(user.Id, user.CurentPlan.Id).Where(x => x.VisibilityDate != null && x.VisibilityDate <= DateTime.UtcNow.Date).FirstOrDefault(); int latestSimulationId = 0; if (usertarget != null && usertarget.UserSimulations != null) { latestSimulationId = usertarget.UserSimulations.Select(x => x.Id).OrderByDescending(x => x).FirstOrDefault(); } planViewModel = this.GetPlan(user, salariesByQuarter, usertarget, latestSimulationId); return(planViewModel); }
public ActionResult Edit(PlanViewModel planViewModel) { if (ModelState.IsValid) { var plan = _db.Plan.SingleOrDefault(p => p.Id == planViewModel.Id); plan.Nazwa = planViewModel.Nazwa; _db.Entry(plan).State = EntityState.Modified; var i = 0; var godziny = _db.Godzina.Where(g => g.PlanId == planViewModel.Id); foreach (var godzina in godziny) { godzina.Godzina1 = planViewModel.Godzina[i].Godzina1; _db.Entry(godzina).State = EntityState.Modified; i++; } i = 0; var przedmioty = _db.Przedmiot.Where(p => p.PlanId == planViewModel.Id); foreach (var przedmiot in przedmioty) { przedmiot.Nazwa = planViewModel.Przedmiot[i].Nazwa; _db.Entry(przedmiot).State = EntityState.Modified; i++; } _db.SaveChanges(); return(RedirectToAction("Index")); } return(View(planViewModel)); }
public ActionResult Edit(PlanViewModel plan) { using (var dtx = new HeimContext()) { var planModel = dtx.Plans.Include("Floors").Single(s => s.ID == plan.ID); //plan.Attributes = planModel.Attributes.ToList(); if (ModelState.IsValid) { planModel.Updated = DateTimeOffset.UtcNow; planModel.Name = plan.Name.Trim(); planModel.Area = plan.Area; planModel.Price = plan.Price; IStorage storage = null; string root = null; // prepare storage if (plan.PreviewImageFile != null && plan.PreviewImageFile.ContentLength > 0 || plan.ModelFile != null && plan.ModelFile.ContentLength > 0) { string fileName = planModel.Updated.UtcTicks.ToString(); root = ConfigurationManager.AppSettings["UserDataRoot"]; root = Path.Combine(root, "plans", plan.ID.ToString()); storage = this.GetStorage(Server.MapPath(root)); storage.EnsureRootExist(); if (plan.PreviewImageFile != null && plan.PreviewImageFile.ContentLength > 0) { string ext = plan.PreviewImageFile.InputStream.GetFileExtension(); ext = ext == null ? null : ext.ToLower(); storage.Save(plan.PreviewImageFile.InputStream, fileName + ext); planModel.PreviewImageFilePath = Path.Combine(root, fileName + ext); } if (plan.ModelFile != null && plan.ModelFile.ContentLength > 0) { string ext = plan.ModelFile.InputStream.GetFileExtension(); ext = ext == null ? null : ext.ToLower(); storage.Save(plan.ModelFile.InputStream, fileName + ext); planModel.ModelFilePath = Path.Combine(root, fileName + ext); } } context.Entry <Plan>(planModel).State = EntityState.Modified; context.SaveChanges(); if (plan.PreviewImageFile == null) { return(RedirectToAction("Index")); } } return(RedirectToAction("Edit", new { id = plan.ID })); } }
public PlanMealViewModel(MainViewModel mainViewModel, PlanViewModel planViewModel, PlanDayViewModel planDayViewModel) { this.mainViewModel = mainViewModel; this.planDayViewModel = planDayViewModel; Consumables = new ObservableCollection <PlanConsumableViewModel>(); Consumables.CollectionChanged += (sender, args) => { if (args.OldItems != null) { foreach (PlanConsumableViewModel viewModel in args.OldItems) { viewModel.PropertyChanged -= ConsumableViewModelUpdated; } } if (args.NewItems != null) { foreach (PlanConsumableViewModel viewModel in args.NewItems) { viewModel.PropertyChanged += ConsumableViewModelUpdated; } } CallUpdate(); }; }
public static PlanViewModel GetCreatedPlan() { PlanViewModel planViewModel = new PlanViewModel(); planViewModel.DaysPerWeek = Plan.DaysPerWeek; planViewModel.HoursPerDay = Plan.HoursPerDay; for (byte day = 0; day < Plan.DaysPerWeek; day++) { for (byte hour = 0; hour < Plan.HoursPerDay; hour++) { foreach (var p in createdPlan.HourPlans[day, hour].ClassToTeacher) { LessonsViewModel lessonsViewModel = new LessonsViewModel(); lessonsViewModel.Day = day; lessonsViewModel.Hour = hour; lessonsViewModel.Subject = p.Value.subject; lessonsViewModel.Teacher = p.Value.teacher; string className = p.Key.Grade + p.Key.ClassName; lessonsViewModel.Class = className; planViewModel.LessonsViewModels.Add(lessonsViewModel); } } } return(planViewModel); }
public ActionResult Details(int Id) { var model = new PlanViewModel(); model.TravelPlanId = Id; var startingPosition = _context.Position .Where(p => p.TravelPlanId == Id && p.PositionType == PositionType.Start) .FirstOrDefault(); model.StartingPointLat = startingPosition?.Latitude; model.StartingPointLon = startingPosition?.Longitude; var endingPosition = _context.Position .Where(p => p.TravelPlanId == Id && p.PositionType == PositionType.End) .FirstOrDefault(); model.EndingPointLat = endingPosition?.Latitude; model.EndingPointLon = endingPosition?.Longitude; var waypoints = _context.Position .Where(p => p.TravelPlanId == Id && p.PositionType == PositionType.WayPoint) .ToList(); model.WaypointsLat = new List <string>(); model.WaypointsLon = new List <string>(); foreach (var waypoint in waypoints) { model.WaypointsLat.Add(waypoint.Latitude); model.WaypointsLon.Add(waypoint.Longitude); } return(View(model)); }
public ActionResult Show(int idPlan) { WSRequest request = new WSRequest("plans/" + idPlan); request.AddAuthorization(Session["token"].ToString()); var response = request.Get(); if (response.Code != 200) { return(RedirectToAction("Index", "Home", new { message = "Não foi possível buscar esse plano" })); } var body = response.Body; //var js = new Newtonsoft.Json.JsonSerializer(); //var mod=js.Deserialize(new System.IO.StringReader(body.ToString()), typeof(PlanViewModel)); var model = new PlanViewModel { IdPlan = (int)body["id_plan"], Name = body["name"].ToString(), Left = (int)body["left"], Price_cents = (int)body["price_cents"], Rewards = body["rewards"].ToString(), }; return(View(model)); }
public ActionResult Planner(DayOfWeek?day) { var userId = User.Identity.GetUserId(); ApplicationUser user = _context.Users.FirstOrDefault(x => x.Id == userId); var dbPlans = _context.Planss.ToList(); PlanViewModel viewModel = new PlanViewModel(); List <Plan> plans = new List <Plan>(); foreach (var plan in dbPlans) { if (plan.User == user) { plans.Add(plan); } } viewModel.Plans = plans; viewModel.RecipesDistribution = _context.PlanRecipeDistributionss.ToList(); viewModel.WorkoutsDistribution = _context.PlanWorkoutDistributionss.ToList(); viewModel.Recipes = _context.Recipess.ToList(); viewModel.Workouts = _context.Workoutss.ToList(); if (day == null) { viewModel.RequestedDay = DateTime.Now.DayOfWeek; } else { viewModel.RequestedDay = day.Value; } return(View(viewModel)); }
public ActionResult Create(PlanViewModel plan) { if (ModelState.IsValid) { WSRequest request = new WSRequest("/plans"); request.AddAuthorization(Session["token"].ToString()); IEnumerable <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("name", plan.Name), //new KeyValuePair<string, string>("id_plan", plan.IdPlan.ToString()), new KeyValuePair <string, string>("left", plan.Left.ToString()), new KeyValuePair <string, string>("price_cents", plan.Price_cents.ToString()), new KeyValuePair <string, string>("rewards", plan.Rewards), }; request.AddJsonParameter(parameters); var response = request.Post(); if (response.Code != 201) { ModelState.AddModelError("", response.Code + ":" + response.Body.GetValue("Message").ToString()); } else { //return RedirectToAction("Show", "Plan", new { idPlan = response.Body.GetValue("id_plan") }); return(RedirectToAction("Index", "Plan", new { idPlan = plan.IdPlan })); } } return(View("New", plan)); //RedirectToAction("New", "Plan", new { error = "Não foi possivel cadastrar" }); }
public PlanViewModel GetPlanViewModelById(string id) { var result = _plans.Get(Guid.Parse(id)); PlanViewModel model = new PlanViewModel(result); return(model); }
public JsonResult Crear(PlanViewModel plan) { var resultado = new baseRespuesta(); resultado = validaciones(plan); if (resultado.ok == true) { EntitiesNoMasAccidentes bd = new EntitiesNoMasAccidentes(); NoMasAccidentes.Models.PLAN planes = new PLAN(); planes.NOMBRE = plan.nombre; planes.VALOR = Int32.Parse(plan.valor); planes.DESCRIPCION = plan.descripcion; planes.ACTIVO = "S"; bd.PLAN.Add(planes); bd.SaveChanges(); resultado.mensaje = "<i class='zmdi zmdi-check zmdi-hc-fw'></i>Plan Registrado Correctamente</br>"; } else { resultado.mensaje = "<b>Error</b></br>" + resultado.mensaje; } return(Json(resultado)); }
private void btnCompletePlan_Click(object sender, RoutedEventArgs e) { try { MessageBoxResult messageBoxResult = MessageBox.Show("Do you really want to complete this plan?", Constants.ApplicationName, MessageBoxButton.YesNo, MessageBoxImage.Warning); if (messageBoxResult == MessageBoxResult.No) { return; } PlanViewModel plan = ((FrameworkElement)sender).DataContext as PlanViewModel; if (plan != null) { using (var applicationDbContext = new ApplicationDbContext()) { var editingPlan = applicationDbContext.Plans.Where(x => x.Id == plan.Id).FirstOrDefault(); if (editingPlan != null) { editingPlan.IsProcessed = true; editingPlan.ModifiedOn = DateTime.Now; // save databases applicationDbContext.SaveChanges(); // notify MessageBox.Show("Successfully completed plan", Constants.ApplicationName, MessageBoxButton.OK, MessageBoxImage.Information); } } // TODO: clone new plan ?? // update UI LoadPlanData(); // reset counter, reset act qty, reset qty plan if (plan.Machine != null) { // reset counter string name = string.Format(PlcTags.BitVariable1, plan.Machine.TagIndex); //Plc.Instance.Write(name, 1); // TODO: comment temporarily // reset expected qty name = string.Format(PlcTags.IntVariable0, plan.Machine.TagIndex); Plc.Instance.Write(name, 0); // reset actual qty name = string.Format(PlcTags.IntVariable1, plan.Machine.TagIndex); Plc.Instance.Write(name, 0); } } } catch (Exception exc) { var msg = exc.GetAllExceptionInfo(); log.Error(msg, exc); MessageBox.Show("Couldn't complete plan", Constants.ApplicationName, MessageBoxButton.OK, MessageBoxImage.Error); } }
public async Task <ActionResult> EditPlan(Guid planGuid) { var draftPlanDTO = await PlanProvider.GetPlan(planGuid); var viewModel = new PlanViewModel(draftPlanDTO); return(View(viewModel)); }
public MainViewModel(PlanViewModel planViewModel, DoseMetricViewModel doseMetricViewModel, DVHViewModel dVHViewModel) { PlanViewModel = planViewModel; DoseMetricViewModel = doseMetricViewModel; DVHViewModel = dVHViewModel; }
void CollapseChild(PlanViewModel parentPlanViewModel) { parentPlanViewModel.IsExpanded = false; foreach (var planViewModel in parentPlanViewModel.Children) { CollapseChild(planViewModel); } }
// GET: webmaster/pagos public ActionResult recibidos(string searchString = "") { if (Session["USER_ID"] != null) { long userId = (long)Session["USER_ID"]; user curUser = entities.users.Find(userId); List <PlanViewModel> paymentList = new List <PlanViewModel>(); List <package> packageList = entities.packages.ToList(); foreach (var item in packageList) { List <community> communityList = entities.communities.Where(m => m.package_id == item.id).ToList(); foreach (var com in communityList) { communuser communuser = entities.communusers.Where(m => m.commun_id == com.id).FirstOrDefault(); if (communuser != null) { user adminUser = entities.users.Find(communuser.user_id); PlanViewModel vm = new PlanViewModel(); vm.packageName = item.first_name; vm.adminEmail = adminUser.email; vm.adminName = adminUser.first_name1 + " " + adminUser.last_name1; List <payment> payList = entities.payments.Where(m => m.to_user_id == adminUser.id).ToList(); decimal p = 0; foreach (var payItem in payList) { if (payItem.quantity != null) { p += (decimal)payItem.quantity; } } vm.payment = p; paymentList.Add(vm); } } } List <ShowMessage> pubMessageList = ep.GetChatMessages(userId); List <contactinfo> contactinfoList = entities.contactinfoes.Where(m => m.user_id == userId).ToList(); List <document_type> document_category_list = entities.document_type.ToList(); recibidosPagosViewModel viewModel = new recibidosPagosViewModel(); viewModel.side_menu = "pagos"; viewModel.side_sub_menu = "recibidos"; viewModel.curUser = curUser; viewModel.document_category_list = document_category_list; viewModel.pubTaskList = ep.GetNotifiTaskList(userId); viewModel.pubMessageList = pubMessageList; viewModel.messageCount = ep.GetUnreadMessageCount(pubMessageList); viewModel.paymentList = paymentList; viewModel.searchString = searchString; return(View(viewModel)); } else { return(Redirect(ep.GetLogoutUrl())); } }
public ActionResult Create(PlanViewModel plan) { if (ModelState.IsValid) { var newPlan = new Plan { Created = DateTimeOffset.UtcNow, Updated = DateTimeOffset.UtcNow, Name = plan.Name.Trim(), Area = plan.Area, Price = plan.Price }; context.Plans.Add(newPlan); context.SaveChanges(); plan.ID = newPlan.ID; if (plan.PreviewImageFile != null || plan.ModelFilePath != null) { string root = ConfigurationManager.AppSettings["UserDataRoot"]; root = Path.Combine(root, "plans", newPlan.ID.ToString()); IStorage storage = this.GetStorage(Server.MapPath(root)); storage.EnsureRootExist(); // Preview string fileName = newPlan.Updated.UtcTicks.ToString(); if (plan.PreviewImageFile != null && plan.PreviewImageFile.ContentLength > 0 || plan.ModelFile != null && plan.ModelFile.ContentLength > 0) { string ext = plan.PreviewImageFile.InputStream.GetFileExtension(); ext = ext == null ? null : ext.ToLower(); storage.Save(plan.PreviewImageFile.InputStream, fileName + ext); newPlan.PreviewImageFilePath = Path.Combine(root, fileName + ext); } if (plan.ModelFile != null && plan.ModelFile.ContentLength > 0) { string ext = plan.ModelFile.InputStream.GetFileExtension(); ext = ext == null ? null : ext.ToLower(); storage.Save(plan.ModelFile.InputStream, fileName + ext); newPlan.ModelFilePath = Path.Combine(root, fileName + ext); } context.Entry <Plan>(newPlan).State = EntityState.Modified; context.SaveChanges(); } return(RedirectToAction("Edit", new { ID = newPlan.ID })); } return(View(plan)); }
public Plan FromPlanViewModelToPlan(PlanViewModel planViewModel) { return(new Plan { Description = planViewModel.Description, BeginnigTimePlan = planViewModel.BeginnigTimePlan, EndTimePlan = planViewModel.EndTimePlan, }); }
public ActionResult Save(PlanViewModel plan, int PlanMasterId, List <PlanDetailViewModel> planDetailList) { if (ModelState.IsValid) { #region //B1: Cập nhật Master PlanModel planModel = _context.PlanModel.Where(p => p.PlanMasterId == PlanMasterId).FirstOrDefault(); planModel.FromTime = plan.FromTime; planModel.ToTime = plan.ToTime; #endregion //B1: Cập nhật Master #region //B2: Cập nhật Detail //TH1: Cũ không có trong mới -> Delete List <PlanDetailModel> detailList = _context.PlanDetailModel.Where(y => y.PlanMasterId == PlanMasterId).ToList(); foreach (var item in detailList) { PlanDetailViewModel pdVM = planDetailList.Where(z => z.PlanDetailId == item.PlanDetailId).FirstOrDefault(); if (pdVM == null) { _context.Entry(item).State = EntityState.Deleted; } } foreach (var item in planDetailList) { //TH2: Mới có trong cũ -> Modify PlanDetailModel planDetail = _context.PlanDetailModel.Where(x => x.PlanDetailId == item.PlanDetailId).FirstOrDefault(); if (planDetail != null) { planDetail.TimeFrame = item.TimeFrame; planDetail.AmountOfCus = item.AmountOfCus; _context.Entry(planDetail).State = System.Data.Entity.EntityState.Modified; } //TH3: Mới không có trong cũ -> Add else { planDetail = new PlanDetailModel(); planDetail.PlanMasterId = PlanMasterId; planDetail.TimeFrame = item.TimeFrame; planDetail.AmountOfCus = item.AmountOfCus; _context.Entry(planDetail).State = System.Data.Entity.EntityState.Added; } } #endregion //B2: Cập nhật Detail #region //B3: Cập nhật Master & Detail _context.Entry(planModel).State = EntityState.Modified; _context.SaveChanges(); #endregion //B3: Cập nhật Master & Detail return(Json(new { result = true }, JsonRequestBehavior.AllowGet)); } return(Json(new { result = false }, JsonRequestBehavior.AllowGet)); }
public Plan() { InitializeComponent(); var viewModel = new PlanViewModel(this.Navigation, null); BindingContext = viewModel; //recipeImage.Source = viewModel.RecipeImage; //btnDom.Command = viewModel.DayCommand; }
// GET: Plan public ActionResult Index() { PlanViewModel _vm = new PlanViewModel(); _vm.Plans = new SelectList(_contextPlan.GetAll(), "Id", "Name"); _vm.Source = new SelectList(_contextAreaCodeSource.GetAll(), "Id", "Code"); _vm.Destiny = new SelectList(_contextAreaCodeDestiny.GetAll(), "Id", "Code"); return(View(_vm)); }
public JsonResult UpdatePlan([DataSourceRequest] DataSourceRequest request, PlanViewModel Plan) { if (Plan == null || !ModelState.IsValid) { return Json(new[] { Plan }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet); } var updatedPlan = this.plansServices.UpdatePlan(Plan); return Json((new[] { updatedPlan }.ToDataSourceResult(request, ModelState)), JsonRequestBehavior.AllowGet); }
private void AddPlan(Plan plan, PlanViewModel parentPlanViewModel) { var planViewModel = new PlanViewModel(plan); _map.Add(plan.UID, planViewModel); if (parentPlanViewModel == null) Plans.Add(planViewModel); else parentPlanViewModel.AddChild(planViewModel); foreach (var childPlan in plan.Children) AddPlan(childPlan, planViewModel); }
public ActionResult <PlanViewModel> PostSchedule([FromBody] Input inputToAdd) { Scheduler scheduler = new Scheduler(inputToAdd); scheduler.CreateSchedule(); GeneticScheduler.GeneticSchedulerMain(scheduler.plans); PlanViewModel planViewModel = GeneticScheduler.GetCreatedPlan(); return(CreatedAtAction("GetSchedule", planViewModel)); }
public IActionResult Valid(PlanViewModel plan) { if (ModelState.IsValid) { return(RedirectToAction("Index")); } else { return(View(plan)); } }
public PlanViewModel UpdatePlan(PlanViewModel plan) { var planFromDb = this.Data.Plans .GetById(plan.Id); planFromDb.Name = plan.Name; this.Data.SaveChanges(); var updatedPlan = this.GetPlanById(plan.Id); return updatedPlan; }
private void AddPlan(Plan planFolder, PlanViewModel parentPlanViewModel) { var planViewModel = new PlanViewModel(planFolder); if (parentPlanViewModel == null) Plans.Add(planViewModel); else parentPlanViewModel.AddChild(planViewModel); var plan = planFolder as Plan; if (plan != null && plan.UID == _elementSubPlan.PlanUID) SelectedPlan = planViewModel; foreach (var childPlan in planFolder.Children) AddPlan(childPlan, planViewModel); }
private void AddPlan(Plan plan, PlanViewModel parentPlanViewModel) { var planViewModel = new PlanViewModel(_plansViewModel, plan); planViewModel.IsExpanded = true; AllPlans.Add(planViewModel); if (parentPlanViewModel == null) Plans.Add(planViewModel); else parentPlanViewModel.AddChild(planViewModel); if (SelectedPlan == null && !planViewModel.IsFolder) SelectedPlan = planViewModel; foreach (var childPlan in plan.Children) AddPlan(childPlan, planViewModel); }
PlanViewModel AddPlan(Plan plan, PlanViewModel parentPlanViewModel) { var planViewModel = new PlanViewModel(plan, Plans); planViewModel.Parent = parentPlanViewModel; var indexOf = Plans.IndexOf(parentPlanViewModel); Plans.Insert(indexOf + 1, planViewModel); foreach (var childPlan in plan.Children) { var childPlanViewModel = AddPlan(childPlan, planViewModel); planViewModel.Children.Add(childPlanViewModel); } return planViewModel; }
private void AddPlan(Plan plan, PlanViewModel parentPlanViewModel) { if ((_filter == null || _filter.Contains(plan.UID)) && !(_isAllPlan && plan.IsNotShowPlan)) { var planViewModel = new PlanViewModel(_plansViewModel, plan); planViewModel.IsExpanded = true; AllPlans.Add(planViewModel); if (parentPlanViewModel == null) Plans.Add(planViewModel); else parentPlanViewModel.AddChild(planViewModel); if (SelectedPlan == null && !planViewModel.IsFolder) SelectedPlan = planViewModel; foreach (var childPlan in plan.Children) AddPlan(childPlan, planViewModel); } }
public void SelectPlan(PlanViewModel planViewModel) { _flushAdorner.Hide(); using (new TimeCounter("\tPlanDesignerViewModel.SelectPlan: {0}", true, true)) { PlanViewModel = planViewModel; Plan = PlanViewModel == null || PlanViewModel.PlanFolder != null ? null : planViewModel.Plan; OnPropertyChanged(() => Plan); OnPropertyChanged(() => IsNotEmpty); using (new WaitWrapper()) if (Plan != null) { using (new TimeCounter("\t\tDesignerCanvas.Initialize: {0}")) DesignerCanvas.Initialize(Plan); using (new TimeCounter("\t\tDesignerItem.Create: {0}")) CreatePresenters(); using (new TimeCounter("\t\tPlanDesignerViewModel.OnUpdated: {0}")) Update(); DesignerCanvas.LoadingFinished(); } } }
public JsonResult DestroyPlan([DataSourceRequest] DataSourceRequest request, PlanViewModel Plan) { var deletedPlan = this.plansServices.DestroyPlan(Plan.Id); return Json(new[] { deletedPlan }, JsonRequestBehavior.AllowGet); }
public override void OnShow() { using (new WaitWrapper()) { base.OnShow(); FiresecManager.UpdatePlansConfiguration(); DesignerCanvas.DeselectAll(); if (DesignerCanvas.Toolbox != null) DesignerCanvas.Toolbox.AcceptKeyboard = true; } if (SelectedPlan == null) SelectedPlan = Plans.FirstOrDefault(); }
void BuildTree() { if (FiresecManager.PlansConfiguration.Plans.IsNotNullOrEmpty()) { foreach (var plan in FiresecManager.PlansConfiguration.Plans) { var planTreeItemViewModel = new PlanViewModel(plan, Plans) { Parent = null, IsExpanded = true }; Plans.Add(planTreeItemViewModel); AddPlan(plan, planTreeItemViewModel); } } }
void AddPlan(Plan parentPlan, PlanViewModel parentPlanTreeItem) { if (parentPlan.Children != null) foreach (var plan in parentPlan.Children) { var planTreeItemViewModel = new PlanViewModel(plan, Plans) { Parent = parentPlanTreeItem, IsExpanded = true }; parentPlanTreeItem.Children.Add(planTreeItemViewModel); Plans.Add(planTreeItemViewModel); AddPlan(plan, planTreeItemViewModel); } }
public MonitorSubPlanToolTipViewModel(PlanViewModel planViewModel) { PlanViewModel = planViewModel; }
void OnRemove() { if (MessageBoxService.ShowConfirmation(string.Format("Вы уверены, что хотите удалить план '{0}'?", SelectedPlan.Plan.Caption)) == System.Windows.MessageBoxResult.Yes) { var selectedPlan = SelectedPlan; var parent = selectedPlan.Parent; var plan = SelectedPlan.Plan; if (parent == null) { selectedPlan.IsExpanded = false; Plans.Remove(selectedPlan); FiresecManager.PlansConfiguration.Plans.Remove(plan); } else { parent.IsExpanded = false; parent.Children.Remove(selectedPlan); parent.Plan.Children.Remove(plan); parent.Update(); parent.IsExpanded = true; } FiresecManager.PlansConfiguration.Update(); ServiceFactory.SaveService.PlansChanged = true; SelectedPlan = Plans.FirstOrDefault(); } }
private void OnSelectedPlanChanged() { if (_initialized) { if (PlanTreeViewModel != null) PlanDesignerViewModel.SelectPlan(PlanTreeViewModel.SelectedPlan); else if (_properties != null && _properties.Plans.Count > 0) { var plan = ClientManager.PlansConfiguration.AllPlans.FirstOrDefault(item => item.UID == _properties.Plans[0]); if (plan != null) { var planViewModel = new PlanViewModel(this, plan); PlanPresenters.ForEach(planPresenter => planViewModel.RegisterPresenter(planPresenter)); PlanDesignerViewModel.SelectPlan(planViewModel); } } } }
void ExpandChild(PlanViewModel parentPlanViewModel) { parentPlanViewModel.IsExpanded = true; foreach (var planViewModel in parentPlanViewModel.Children) { ExpandChild(planViewModel); } }
private bool FindElementOnPlan(PlanViewModel plan, List<Guid> deviceUIDs) { foreach (var element in plan.Plan.ElementUnion) if (deviceUIDs.Contains(element.UID)) { PlanTreeViewModel.SelectedPlan = plan; OnShowElement(element.UID); return true; } return false; }
void OnAddSubPlan() { var planDetailsViewModel = new DesignerPropertiesViewModel(null); if (DialogService.ShowModalWindow(planDetailsViewModel)) { var plan = planDetailsViewModel.Plan; var planViewModel = new PlanViewModel(plan, Plans); SelectedPlan.Children.Add(planViewModel); SelectedPlan.Plan.Children.Add(plan); planViewModel.Parent = SelectedPlan; plan.Parent = SelectedPlan.Plan; SelectedPlan.Update(); SelectedPlan = planViewModel; FiresecManager.PlansConfiguration.Update(); ServiceFactory.SaveService.PlansChanged = true; } }
private PlanViewModel AddPlan(Plan plan, PlanViewModel parentPlanViewModel) { var planViewModel = new PlanViewModel(plan); if (parentPlanViewModel == null) Plans.Add(planViewModel); else parentPlanViewModel.AddChild(planViewModel); if (SelectedPlan == null && !planViewModel.IsFolder) SelectedPlan = planViewModel; foreach (var childPlan in plan.Children) AddPlan(childPlan, planViewModel); return planViewModel; }
public void Initialize() { Plans = new ObservableCollection<PlanViewModel>(); foreach (var plan in FiresecManager.PlansConfiguration.Plans) AddPlan(plan, null); for (int i = 0; i < Plans.Count; i++) { CollapseChild(Plans[i]); ExpandChild(Plans[i]); } SelectedPlan = null; }
private void OnAddSubFolder() { var viewModel = new FolderPropertiesViewModel(null); if (DialogService.ShowModalWindow(viewModel)) { var planFolder = viewModel.PlanFolder; var planViewModel = new PlanViewModel(planFolder); SelectedPlan.AddChild(planViewModel); SelectedPlan.Plan.Children.Add(planFolder); SelectedPlan.Update(); SelectedPlan = planViewModel; FiresecManager.PlansConfiguration.Update(); ServiceFactory.SaveService.PlansChanged = true; } }
void OnShowElementDevice(Guid deviceUID) { foreach (var plan in Plans) foreach (var elementDevice in plan.Plan.ElementUnion) if (elementDevice.UID == deviceUID) { SelectedPlan = plan; OnShowElement(deviceUID); return; } }