public async Task <List <MetricFeature> > Create(CreateTagModel model) { ApplicationUser user = await _context.Users.Where(f => f.Email == model.UserEmail).FirstOrDefaultAsync(); Feature feature = await _context.Feature.Where(f => f.Name == model.Tag).FirstOrDefaultAsync(); if (feature == null) { feature = new Feature { Name = model.Tag }; _context.Feature.Add(feature); _context.SaveChanges(); } var newFeature = new MetricFeature { User = user, Date = DateTime.Now, Duration = model.Duration, PdfId = model.PdfId, Feature = feature, FeatureId = feature.FeatureId }; _context.MetricFeature.Add(newFeature); _context.SaveChanges(); return(_context.MetricFeature.ToList()); }
public async Task <int> CreateUser([FromBody] CreateTagModel model) { var result = 0; result = await Server.CreateTag(model.Name, model.Description); return(result); }
public IActionResult Create(CreateTagModel tag) { if (!this.ModelState.IsValid) { return(this.View()); } this.tagService.Create(tag); return(this.RedirectToAction("All", "Tag")); }
public void Create(CreateTagModel model) { var tag = new Data.Models.Tag { Name = model.Name }; this.tagRepsitory.AddAsync(tag); this.tagRepsitory.SaveChangesAsync(); }
public JsonResult CreateTag(CreateTagModel tagModel) { try { Tag tag = new Tag() { Name = tagModel.Name }; DatabaseContext.Tags.Add(tag); DatabaseContext.SaveChanges(); return(Json(new { result = true })); } catch (Exception e) { Logger.Error(e.Message); return(Json(new { result = false })); } }
public async Task <bool> Create(CreateTagModel model, CancellationToken token = default) { var tag = model.MapToTag(_scopeControl.GetUserId()); if (tag.IsInValid()) { _scopeControl.AddNotifications(tag.Notifications); return(false); } if (token.IsCancellationRequested) { return(false); } _repository.Add(tag); return(await _repository.UnitOfWork.Commit(token)); }
public async Task <IActionResult> Create(CreateTagModel model, CancellationToken token = default) { await _service.Create(model, token); return(ApiCreatedResponse()); }