public async Task <IActionResult> CreateScheme(SRSObjectIndustrialSchemeInputModel model, int id)
        {
            try
            {
                if (!this.ModelState.IsValid)
                {
                    return(this.View(model));
                }

                if (model.Hour.Hours < 8 || model.Hour.Hours > 19)
                {
                    this.ModelState.AddModelError(string.Empty, "Hour must be between 8 and 19!");
                    return(this.View(model));
                }

                var user = await this.userManager.GetUserAsync(this.User);

                await this.srsObjectIndustrialService.CreateSchemeAsync(model, id, user.Id);

                this.TempData["Message"] = "Scheme was added successfully.";

                return(this.RedirectToAction("AllSchemes", new { id }));
            }
            catch (Exception ex)
            {
                this.ModelState.AddModelError(string.Empty, ex.Message);
                return(this.View());
            }
        }
예제 #2
0
        public async Task CreateSchemeAsync(SRSObjectIndustrialSchemeInputModel input, int id, string userId)
        {
            var schema = new SrsobjectIndustrialSchema
            {
                SrsobjectIndustrialId = id,
                EntryDate             = input.EntryDate,
                WeekDay       = (byte)input.WeekDay,
                Hour          = input.Hour,
                AddedByUserId = userId,
            };

            await this.srsObjectIndurstiralSchemaRepository.AddAsync(schema);

            await this.srsObjectIndurstiralSchemaRepository.SaveChangesAsync();
        }
        public IActionResult CreateScheme()
        {
            var viewModel = new SRSObjectIndustrialSchemeInputModel();

            return(this.View(viewModel));
        }