public ActionResult Update(ContainerModel model) { var ipAddress = GetIP(Request); if (ModelState.IsValid) { var user = Converter.UserModelToUser(model); // check choices consistency var places = FoodChoiceService.GetPlaces(); ValidationService.RemoveInvalidEntry(user, places); var errorMessage = string.Empty; if (ValidationService.ControlCheckBoxes(user, out errorMessage)) { FoodChoiceService.UpdateUser(user, ipAddress); logger.Debug("Modification de l'utilisateur: {0} - IP: {1}", user.Name, ipAddress); } return(RedirectToAction("Index")); } else { // errors are not managed logger.Error("Erreur lors de la modification: {0} - IP: {1}", model.FoodChoice.Name, ipAddress); return(RedirectToAction("Index")); } }
public ActionResult Index() { var places = FoodChoiceService.GetPlaces(); var usersChoices = FoodChoiceService.GetTodayUsersChoices(); var ipAddress = GetIP(Request); #if DEBUG var userAlreadyRegistered = false; User user = null; #else var userAlreadyRegistered = FoodChoiceService.UserAlreadyRegisteredToday(ipAddress); var user = FoodChoiceService.FindUserByIpAddress(ipAddress); #endif var model = new ContainerModel() { // empty form FoodChoice = new UserModel { Name = user == null ? null : user.Name }, // users choices list UsersChoices = Converter.UsersToUserModels(usersChoices), // places list Places = Converter.PlacesToPlaceModels(places), IpVisitor = ipAddress, ShowForm = !userAlreadyRegistered }; return(View(model)); }
public void Controller_AddOneOrMoreChoicesAndSeats() { var model = new ContainerModel { FoodChoice = new UserModel { Name = "Charles", NumberOfAvailableSeats = 3 }, Choices = new List <ChoiceModel> { new ChoiceModel { PlaceId = 1 }, new ChoiceModel { PlaceId = 5 } } }; var routeResult = (RedirectToRouteResult)controller.Add(model); var method = routeResult.RouteValues.First().Value.ToString(); Assert.AreEqual("Index", method); }
public async Task <int> UpdateContainer([FromBody] ContainerModel container, int containerId) { container.ContainerId = containerId; containerId = await _containerRepository.InsertUpdateContainerAsync(container).ConfigureAwait(false); return(containerId); }
/// <summary> /// Gets the data. /// </summary> /// <param name="bindingList">The binding list.</param> /// <returns> /// BindingList with models of type T /// </returns> /// <exception cref="Exception">An error occurred</exception> public string GetData(ContainerModel <T> bindingList) { if (bindingList == null) { return(string.Empty); } try { var xmlserializer = new XmlSerializer(typeof(ContainerModel <T>)); var stringWriter = new StringWriter(); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = "\t"; using (var writer = XmlWriter.Create(stringWriter, settings)) { xmlserializer.Serialize(writer, bindingList); return(stringWriter.ToString()); } } catch (Exception ex) { throw new Exception("An error occurred", ex); } }
//persistence //should be fixed now public override void SetExtraData(Dictionary <string, object> data) //this either isn't called or doesn't work { if (UseLocalContainer && UsePersistentContainer) { MyContainer = SerializableContainerModel.MakeContainerModel((SerializableContainerModel)data["Container"]); } }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="year"></param> /// <param name="number"></param> /// <param name="subject"></param> /// <param name="category"></param> /// <param name="container"></param> /// <param name="location"></param> public DocumentUnitModel(Guid id, short year, long number, string subject, CategoryModel category, ContainerModel container, string location) : base(id) { DocumentUnitAttribute documentUnitAttribute = Attribute.GetCustomAttribute(GetType(), typeof(DocumentUnitAttribute)) as DocumentUnitAttribute; if (documentUnitAttribute == null) { throw new ArgumentNullException("Unità documentaria definita senza gli attributi di sviluppo. Anomalia critica."); } if (category == null) { throw new ArgumentNullException("Unità documentaria non può essere inizializzata senza un classificatore."); } if (container == null) { throw new ArgumentNullException("Unità documentaria non può essere inizializzata senza un contenitore archivistico."); } Category = category; Container = container; DocumentUnitType = documentUnitAttribute.DocumentUnitType; Year = year; Number = number; DocumentUnitName = documentUnitAttribute.DocumentUnitName; Title = string.Concat(year.ToString("0000"), "/", number.ToString("0000000")); Subject = subject; Location = location; Name = string.Concat(DocumentUnitName, " ", Title); }
public Project1UIDesignContainer() { //this.DefaultStyleKey = typeof(Project1UIDesignContainer); this.Background = Brushes.Transparent; Loaded += Project1UIDesignContainer_Loaded; containerModel = new ContainerModel(); containerModel.Background = Brushes.White; containerModel.Opacity = .8; Border container = new Border(); container.Width = Double.NaN; container.Height = Double.NaN; container.SetValue(ZIndexProperty, -1); this.Children.Add(container); BindingOperations.SetBinding(container, BackgroundProperty, new Binding() { Source = containerModel, Path = new PropertyPath("Background"), Mode = BindingMode.OneWay, }); BindingOperations.SetBinding(container, OpacityProperty, new Binding() { Source = containerModel, Path = new PropertyPath("Opacity"), Mode = BindingMode.OneWay, }); }
private ContainerModel GetContainerModel(int userId) { var container = new ContainerModel(); //container.Title = "My Notes"; using (var slideDb = new SlideContext()) { var homeFolder = slideDb.Folders.FirstOrDefault(f => f.UserId == userId && f.ParentId == null); var childFolders = slideDb.Folders.Where(f => f.ParentId == homeFolder.Id).ToList(); var notes = slideDb.Notes.Where(n => n.ParentId == homeFolder.Id).ToList(); container.Folders = MapFolderModel(childFolders); container.Notes = MapNoteModel(notes); } container.BreadCrumb = new List <BreadCrumbModel> { new BreadCrumbModel { Title = "Home", FolderId = 1, IsActive = false }, new BreadCrumbModel { Title = "My Notes", FolderId = 2, IsActive = true } }; return(container); }
private async void createBtn_Clicked(object sender, EventArgs e) { Random rand = new Random(); //Assemble our new container var temp = new ContainerModel(); temp.Destination = _ViewModel.Destination; temp.ImageFile = _ViewModel.ImageSrc; temp.Id = rand.Next(0, 10000); try { //Get our list from json var list = JsonConvert.DeserializeObject <List <ContainerModel> >(Settings.ContainerSetting); //Add the new one list.Insert(0, temp); //Reserialize var json = JsonConvert.SerializeObject(list); Debug.WriteLine(json); //Save Settings.ContainerSetting = json; createBtn.IsVisible = false; } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); } //Destroy the page and go back to previous. await Navigation.PopAsync(); }
public HomeController(ILogger <HomeController> logger, UserManager <IdentityUser> userManager, ApplicationDbContext context, SignInManager <IdentityUser> signInManager) { _logger = logger; this.userManager = userManager; this.context = context; this.signInManager = signInManager; model = new ContainerModel(); }
internal override void EnsureConstructed() { if (ParentModel == null) { _containerModel = new ContainerModel(this); Debug.Assert(ParentModel == _containerModel); } }
internal virtual void EnsureConstructed() { if (ParentModel == null) { var containerModel = new ContainerModel(this); Debug.Assert(ParentModel == containerModel); } }
public ProtocolModel(Guid id, short year, int number, string subject, CategoryModel category, ContainerModel container, string location) : base(id, year, number, subject, category, container, location) { Documents = new HashSet <DocumentModel>(); Contacts = new HashSet <ProtocolContactModel>(); Sectors = new HashSet <ProtocolSectorModel>(); Users = new HashSet <ProtocolUserModel>(); }
public bool AddContainer() { ContainerModel item = new ContainerModel(); ContainerAbstractionStructure.containers.Add(item); item.id = Guid.NewGuid().ToString(); _containers.Add(item); return(true); }
private static ContainerModel ReadModel(IDataRecord reader) { var id = reader.GetInt32(0); var data = reader.GetInt16(1); var errorLogModel = new ContainerModel(id, (byte)data); return(errorLogModel); }
private void SaveCommandExecute() { var container = new ContainerModel() { Scripts = this.Scripts.Select(o => o.AttatchedDatamodel).ToList() }; this.persistingService.Save(container); }
public void Init() { FindComponents(); if (CorpseContainer == null && CorpseItems?.Items != null && CorpseItems.Items.Length > 0) { CorpseContainer = SerializableContainerModel.MakeContainerModel(CorpseItems); } }
public static void PushModal(InventoryModel inventory, ContainerModel container, bool isShop, ContainerCallback callback) { var go = Instantiate <GameObject>(CoreUtils.LoadResource <GameObject>(DefaultPrefab), CoreUtils.GetWorldRoot()); var modal = go.GetComponent <ContainerModal>(); modal.Inventory = inventory; modal.Container = container; modal.IsShop = isShop; modal.Callback = callback; }
public static IHtmlContent SectionHeader(this IHtmlHelper helper, string textId = null, IHtmlContent content = null, string classes = "", object attrs = null) { var mod = new ContainerModel { TitleContent = content ?? helper.Word(textId), Attributes = attrs, TitleTextId = classes }; return(helper.GetComponent("Components/SectionHead", mod)); }
// Use this for initialization void Start() { var loadedContainer = FindObjectOfType <GameManager>().Game.Scene.Containers.FirstOrDefault(c => c.ContainerId == ContainerId); State = loadedContainer; cx = GameManager.ScreenXCenter - Gump.width / 2; cy = GameManager.ScreenYCenter - Gump.height / 2; centreW = State.Width / 2; centreH = State.Height / 2; }
public override void Start() { base.Start(); if (!UseLocalContainer) { MyContainer = GameState.Instance.ContainerState[SharedContainer]; } else if (MyContainer == null) //should fix... { MyContainer = SerializableContainerModel.MakeContainerModel(LocalContainer); //called after and overriding save? } }
public virtual IHtmlContent TabTitle(IHtmlHelper helper, string containerId, string activationVariable, string textId, IHtmlContent content, object attr) { var m = new ContainerModel { ContainerId = containerId, ActivationProperty = activationVariable, TitleTextId = textId ?? containerId, Attributes = attr, TitleContent = content }; return(helper.GetComponent("Components/TabTitle", m)); }
public void Controller_AddWithSameName() { var model = new ContainerModel { FoodChoice = new UserModel { Name = "Michel" } }; var viewResult = (ViewResult)controller.Add(model); Assert.AreEqual("Le nom existe déjà !", GetErrorMessage(viewResult)); }
public void Controller_TODO() { var model = new ContainerModel { FoodChoice = new UserModel { Name = "Bob" } }; var viewResult = (ViewResult)controller.Add(model); Assert.AreEqual("Merci de cocher au moins une case !", GetErrorMessage(viewResult)); }
public override void Start() { base.Start(); if (!UseLocalContainer) { MyContainer = GameState.Instance.ContainerState[SharedContainer]; } else if (MyContainer == null) //should fix... { MyContainer = SerializableContainerModel.MakeContainerModel(LocalContainer); //called after and overriding save? } TryExecuteOnComponents(component => component.Init(this)); Initialized = true; }
public void Controller_AddWithNameButNoChoice() { var model = new ContainerModel { FoodChoice = new UserModel { Name = "Simon", }, Choices = new List <ChoiceModel>() }; var viewResult = (ViewResult)controller.Add(model); Assert.AreEqual("Merci de cocher au moins une case !", GetErrorMessage(viewResult)); }
public async Task <int> InsertUpdateContainerAsync(ContainerModel container) { using (var connection = _dbConnection()) { var parameters = new DynamicParameters(); parameters.Add("@ContainerID", container.ContainerId > 0 ? container.ContainerId : (int?)null, DbType.Int32, ParameterDirection.Input); parameters.Add("@ContainerName", container.ContainerName, DbType.String, ParameterDirection.Input); parameters.Add("@UserID", container.UserId, DbType.Int32, ParameterDirection.Input); parameters.Add("@IsDefault", container.IsDefault, DbType.Boolean, ParameterDirection.Input); parameters.Add("@NewContainerID", null, dbType: DbType.Int32, direction: ParameterDirection.Output); var result = await connection.ExecuteAsync(InsertUpdateContainerProc, parameters, commandType : CommandType.StoredProcedure).ConfigureAwait(false); var containerId = parameters.Get <int>("NewContainerID"); return(containerId); } }
public bool AddBucketToContainer(BucketModel bucket) { bool found = false; if (!_containers.Any()) { var item = new ContainerModel { id = Guid.NewGuid().ToString(), CurrentContentValue = bucket.MaxCapacity, BucketsStoredInsideThisContainer = new List <BucketModel> { bucket } }; StaticResources.CurrentStaticContainer.currentContainer = item; _containers.Add(item); Console.WriteLine("Bucket and container added"); } foreach (var item in _containers) { if (found == false) { if (item.MaxCapacity > item.CurrentContentValue) { item.BucketsStoredInsideThisContainer.Add(bucket); item.CurrentContentValue = bucket.MaxCapacity; found = true; Console.WriteLine("Bucket added"); } } } if (found == false) { ContainerModel item = new ContainerModel(); ContainerAbstractionStructure.containers = new List <ContainerModel>(); ContainerAbstractionStructure.containers.Add(item); item.id = Guid.NewGuid().ToString(); item.BucketsStoredInsideThisContainer = new List <BucketModel>(); item.BucketsStoredInsideThisContainer.Add(bucket); item.CurrentContentValue = bucket.MaxCapacity; _containers.Add(item); Console.WriteLine("Bucket and container added"); } return(true); }
public ActionResult Add(ContainerModel model) { var usersChoices = FoodChoiceService.GetTodayUsersChoices(); var ipAddress = GetIP(Request); if (ModelState.IsValid) { var user = Converter.UserModelToUser(model); // check choices consistency var places = FoodChoiceService.GetPlaces(); ValidationService.RemoveInvalidEntry(user, places); var errorMessage = string.Empty; var allControlsAreOk = ValidationService.DoAllControls(user, usersChoices, out errorMessage); if (allControlsAreOk) { user.IpAddress = ipAddress; FoodChoiceService.AddUser(user); logger.Debug("Ajout de l'utilisateur: {0} - IP: {1}", user.Name, user.IpAddress); return(RedirectToAction("Index")); } else { ModelState.AddModelError("Error", errorMessage); model.UsersChoices = Converter.UsersToUserModels(usersChoices); model.IpVisitor = ipAddress; model.Places = Converter.PlacesToPlaceModels(FoodChoiceService.GetPlaces()); model.ShowForm = true; logger.Error("Erreur lors de l'ajout: {0} - IP: {1} - erreur: {2}", model.FoodChoice.Name, model.IpVisitor, errorMessage); return(View("Index", model)); } } else { var allPlaces = FoodChoiceService.GetPlaces(); model.UsersChoices = Converter.UsersToUserModels(usersChoices); model.Places = Converter.PlacesToPlaceModels(allPlaces); model.ShowForm = true; logger.Error("Erreur lors de l'ajout: {0} - IP: {1}", model.FoodChoice.Name, ipAddress); return(View("Index", model)); } }