示例#1
0
        public async Task <IActionResult> Add(InputTransportViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }
            var transport = await this._transportsService.Add(model);

            this.TempData[GlobalConstants.SuccessMessageKey] = "Transport" + GlobalConstants.SuccessfullyAddedMessage;
            return(this.Redirect("Add"));
        }
示例#2
0
        public async Task <int> Add(InputTransportViewModel model)
        {
            var company   = this._companiesService.GetById(model.CompanyId);
            var transport = new Transport
            {
                LastSeatNumber    = 0,
                Company           = company,
                TransportType     = model.TransportType,
                DesignationNumber = model.Number,
            };

            await this._transportRepository.AddAsync(transport);

            await this._transportRepository.SaveChangesAsync();

            return(transport.Id);
        }