// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, APIDBContext apiContext) { using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope()) { var context = serviceScope.ServiceProvider.GetRequiredService <APIDBContext>(); context.Database.Migrate(); DummyDataParser dummyParser = new DummyDataParser(); dummyParser.AddDummyBlogPostDataIfNeeded(ref context); dummyParser.AddDummyUserDataIfNeeded(ref context); } if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "API v1")); } apiContext.Database.EnsureCreated(); app.UseHttpsRedirection(); app.UseAuthentication(); app.UseRouting(); app.UseCors("CorsPolicy"); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public UsersController(IUserService userService, IMapper mapper, IOptions <AppSettings> appSettings, APIDBContext context) { _userService = userService; _mapper = mapper; _appSettings = appSettings.Value; _context = context; }
public void PostChild(int id, [FromBody] Location location) { using (var dataContext = new APIDBContext()) { location.Parent = dataContext.Locations.Find(id); dataContext.Locations.Add(location); dataContext.SaveChanges(); } }
public void Post([FromBody] ItemFieldValue value) { // TODO: Add data validation using (var dataContext = new APIDBContext()) { dataContext.ItemFieldValues.Add(value); dataContext.SaveChanges(); } }
public void Post([FromBody] ItemAttachment attachment) { // TODO: Add data validation using (var dataContext = new APIDBContext()) { dataContext.ItemAttachments.Add(attachment); dataContext.SaveChanges(); } }
public void Post([FromBody] Category category) { // TODO: Add data validation using (var dataContext = new APIDBContext()) { dataContext.Categories.Add(category); dataContext.SaveChanges(); } }
public void PostChild(int id, [FromBody] Category category) { using (var dataContext = new APIDBContext()) { category.Parent = dataContext.Categories.Find(id); dataContext.Categories.Add(category); dataContext.SaveChanges(); } }
public void Post([FromBody] ItemTag tag) { // TODO: Add data validation using (var dataContext = new APIDBContext()) { dataContext.ItemTags.Add(tag); dataContext.SaveChanges(); } }
public void Post([FromBody] Location location) { // TODO: Add data validation using (var dataContext = new APIDBContext()) { dataContext.Locations.Add(location); dataContext.SaveChanges(); } }
public void Put(int id, [FromBody] ItemFieldValue value) { // TODO: Add data validation value.ID = id; using (var dataContext = new APIDBContext()) { dataContext.ItemFieldValues.Update(value); dataContext.SaveChanges(); } }
public void Put(int id, [FromBody] Category category) { // TODO: Add data validation category.ID = id; using (var dataContext = new APIDBContext()) { dataContext.Categories.Update(category); dataContext.SaveChanges(); } }
public void Put(int id, [FromBody] ItemTag tag) { // TODO: Add data validation tag.ID = id; using (var dataContext = new APIDBContext()) { dataContext.ItemTags.Update(tag); dataContext.SaveChanges(); } }
public void Put(int id, [FromBody] Location location) { // TODO: Add data validation location.ID = id; using (var dataContext = new APIDBContext()) { dataContext.Locations.Update(location); dataContext.SaveChanges(); } }
public void Put(int id, [FromBody] ItemAttachment attachment) { // TODO: Add data validation attachment.ID = id; using (var dataContext = new APIDBContext()) { dataContext.ItemAttachments.Update(attachment); dataContext.SaveChanges(); } }
public void Delete(int id) { ItemAttachment attachment = new ItemAttachment(); attachment.ID = id; using (var dataContext = new APIDBContext()) { dataContext.ItemAttachments.Remove(attachment); dataContext.SaveChanges(); } }
public ActionResult <List <ItemFieldValue> > Get() { List <ItemFieldValue> dataValues = new List <ItemFieldValue>(); using (var dataContext = new APIDBContext()) { dataValues = dataContext.ItemFieldValues.AsQueryable().ToList(); return(dataValues); } }
public ActionResult <List <ItemAttachment> > Get() { List <ItemAttachment> dataAttachments = new List <ItemAttachment>(); using (var dataContext = new APIDBContext()) { dataAttachments = dataContext.ItemAttachments.AsQueryable().ToList(); return(dataAttachments); } }
public void Delete(int id) { ItemFieldValue value = new ItemFieldValue(); value.ID = id; using (var dataContext = new APIDBContext()) { dataContext.ItemFieldValues.Remove(value); dataContext.SaveChanges(); } }
public void Delete(int id) { Location location = new Location(); location.ID = id; using (var dataContext = new APIDBContext()) { dataContext.Locations.Remove(location); dataContext.SaveChanges(); } }
public ActionResult <List <ItemTag> > Get() { List <ItemTag> dataTags = new List <ItemTag>(); using (var dataContext = new APIDBContext()) { dataTags = dataContext.ItemTags.AsQueryable().ToList(); return(dataTags); } }
public List <User> GetUser() { List <User> user = new List <User>(); using (var db = new APIDBContext()) { user = db.user.ToList(); } return(user); }
public ActionResult <List <Location> > Get() { List <Location> dataLocations = new List <Location>(); using (var dataContext = new APIDBContext()) { dataLocations = dataContext.Locations.AsQueryable().ToList(); return(dataLocations); } }
public void Delete(int id) { ItemTag tag = new ItemTag(); tag.ID = id; using (var dataContext = new APIDBContext()) { dataContext.ItemTags.Remove(tag); dataContext.SaveChanges(); } }
public ActionResult <List <Category> > Get() { List <Category> dataCategories = new List <Category>(); using (var dataContext = new APIDBContext()) { dataCategories = dataContext.Categories.AsQueryable().ToList(); return(dataCategories); } }
public void Delete(int id) { ItemField itemField = new ItemField(); itemField.ID = id; using (var dataContext = new APIDBContext()) { dataContext.ItemFields.Remove(itemField); dataContext.SaveChanges(); } }
public void Delete(int id) { Category category = new Category(); category.ID = id; using (var dataContext = new APIDBContext()) { dataContext.Categories.Remove(category); dataContext.SaveChanges(); } }
public IActionResult Delete(int id) { Item item = new Item(); item.ID = id; using (var dataContext = new APIDBContext()) { dataContext.Items.Remove(item); dataContext.SaveChanges(); return(Ok()); } }
public List <UserProject> GetUserProject() { List <UserProject> user_project = new List <UserProject>(); using (var db = new APIDBContext()) { user_project = db.userProject.FromSql("EXECUTE dbo.GetUserProject").ToList(); } return(user_project);; }
public List <User> GetUserProc() { List <User> user = new List <User>(); using (var db = new APIDBContext()) { user = db.user.FromSql("EXECUTE dbo.GetUsers").ToList(); } return(user); }
public CustomerController(APIDBContext context) { dbContext = context; settings = new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore, Error = (sender, args) => { args.ErrorContext.Handled = true; }, }; }