Example #1
0
        public async Task <IActionResult> Create(RequestsStoreViewModel model)
        {
            if (model == null)
            {
                return(StatusCode(StatusCodes.Status400BadRequest));
            }
            model.Requests.CreateDate = DateTime.Now;
            model.Date     = DateTime.Now;
            model.StatusId = repository.Statuses.Single(a => a.StatusID == 1).StatusID;
            model.Comments = "Заявка создана";

            ModelState.Remove("Comments");
            // ModelState.AddModelError("Comments", new ModelState());
            if (ModelState.IsValid)
            {
                await repository.AddRequest((RequestsStore)modelMapper.Map(model, typeof(RequestsStoreViewModel), typeof(RequestsStore)));

                return(RedirectToAction("Index"));
            }
            ;

            return(View(model));
        }
Example #2
0
        /// <summary>
        /// Creates and initalize a <typeparamref name="Request"/>
        /// </summary>
        /// <param name="message">BeginRequest message</param>
        protected virtual void BeginRequest(Message message)
        {
            if (message.Header.RecordType != RecordType.Application)
            {
                return;
            }

            if (message.Body.Count < Consts.ChunkSize)
            {
                return;
            }

            _requestsRepository.AddRequest(CreateRequestInternal(message));
        }