public bool CreateStorageArea(StorageAreaCreate model)
        {
            var entity =
                new StorageArea()//Creating an instance of a new StorageArea
            {
                NameOfStorageArea = model.NameOfStorageArea,
                GameType          = model.GameType,
            };

            using (var ctx = new ApplicationDbContext())//Saving the created storage to the database
            {
                ctx.StorageAreas.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }//End public CreateStorageArea
Exemplo n.º 2
0
        public IHttpActionResult Post(StorageAreaCreate storageArea)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateStorageAreaService();

            if (!service.CreateStorageArea(storageArea))
            {
                return(InternalServerError());
            }

            return(Ok());
        }