public IActionResult Create([FromBody] AreaCreate model) { try { var result = _areaService.Create(model); return(Ok(result)); } catch (Exception e) { return(BadRequest(e)); } }
//Create new area public async Task <bool> CreateArea(AreaCreate model) { Area area = new Area() { AreaName = model.AreaName, Active = true, BuildingId = model.BuildingId }; _context.Areas.Add(area); return(await _context.SaveChangesAsync() == 1); }
public IHttpActionResult Post(AreaCreate area) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateAreaService(); if (!service.CreateArea(area)) { return(InternalServerError()); } return(Ok()); }
public bool CreateMenu(AreaCreate model) { var entity = new Area() { AreaName = model.AreaName, }; using (var ctx = new ApplicationDbContext()) { ctx.Area.Add(entity); return(ctx.SaveChanges() == 1); } }
//private readonly Guid _userId; //public AreaService(Guid userId) //pass in member variable and store it until it's needed //{ // _userId = userId; //} Commenting out these lines makes it so that I do not need a userId to create an AreaService. public bool CreateArea(AreaCreate model) { var location = new Area() { AreaName = model.AreaName, ParkId = model.ParkId, }; using (var loc = new ApplicationDbContext()) { loc.Areas.Add(location); return(loc.SaveChanges() == 1); } }
public Area Create(AreaCreate model) { Area area = new Area { AreaGroupId = model.AreaGroupId, AreaName = model.AreaName, CityId = model.CityId, DriverPrice = model.DriverPrice, AreaGuid = Guid.NewGuid() }; _db.Areas.Add(area); _db.SaveChanges(); return(area); }
public async Task <bool> CreateAreaAsync(AreaCreate model) { var entity = new Area() { // OwnerID = _userId, AreaName = model.AreaName, }; using (var ctx = new ApplicationDbContext()) { ctx.Area.Add(entity); return(await ctx.SaveChangesAsync() == 1); } }
//Dictionary<Entity, float> entitySpeed = new Dictionary<Entity, float>(); private void Start() { area = new AreaCreate(AreaCreate.Area.up); foreach (var i in enemies) { i.speed = kSpeed / i.startSpeed; } //foreach(var i in enemies) { // GameObject go = new GameObject(); // Generate g = go.AddComponent<Generate>(); // g.Init(i.Key, i.Value*enemies.Count, areaCreate,k); // Debug.Log(g.avengerTime); //} time = k / avengerTime; }
public async Task <IHttpActionResult> CreateArea(AreaCreate area) { //check if model is valid if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //instantiate area service AreaService service = CreateAreaService(); if (await service.CreateArea(area) == false) { return(InternalServerError()); } return(Ok()); //200 }
public async Task <ActionResult> Create(AreaCreate note) { if (!ModelState.IsValid) { ViewBag.AreaId = await GetAreaAsync(); return(View(note)); } var service = CreateAreaService(); if (await service.CreateAreaAsync(note)) { TempData["SaveResult"] = "Area was created."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Area could not be created."); ViewBag.AreaId = await GetAreaAsync(); return(View(note)); }