Beispiel #1
0
        public async Task <IActionResult> Create(CreateAssetBindingModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }

            await this.assetService.Create(model, this.User.Identity.Name);

            return(this.RedirectToAction(ActionConstants.Index, ControllerConstants.Assets));
        }
Beispiel #2
0
        public async Task <int> Create(CreateAssetBindingModel model, string username)
        {
            Validator.ThrowIfNull(model);

            var client = await this.GetUserByNamedAsync(username);

            var asset = this.Mapper.Map <Asset>(model);

            asset.VendorId  = client.Id;
            asset.CreatedAt = DateTime.Now;

            await this.Repository.AddAsync(asset);

            await this.Repository.SaveChangesAsync();

            return(asset.Id);
        }