public ViewResult Misc3(int?numEmployees)
        {
            TemplateModelMisc templateModel = new TemplateModelMisc();

            while (numEmployees > 0)
            {
                PersonMisc p = new PersonMisc();
                templateModel.AddEmployeeMisc(p);
                numEmployees -= 1;
            }
            return(View("Elevator", templateModel));
        }
Exemplo n.º 2
0
        public async Task <IHttpActionResult> PostPersonMisc(ViewModels.PersonMiscellaneous dto)
        {
            // return Ok(client);
            if (dto == null)
            {
                return(Exceptions.getNullException(ModelState));
            }
            if (!ModelState.IsValid)
            {
                // return BadRequest(ModelState);
                return(Exceptions.getModelValidationException(ModelState));
            }
            var validate = unitOfWork.PersonMiscRepository.Validate(dto);

            if (validate.Code != HttpStatusCode.OK)
            {
                return(validate);
            }

            PersonMisc entity = null;

            if (dto.Id == -1)
            {
                entity = new PersonMisc();
                unitOfWork.PersonMiscRepository.Insert(entity);
            }

            else
            {
                entity = await unitOfWork.PersonMiscRepository.GetByID(dto.Id);
            }

            if (entity == null)
            {
                return(Exceptions.getNotFoundException());
            }

            //ViewModels.Location.Fill(entity, dto);
            ViewModels.PersonMiscellaneous.Fill(entity, dto);



            var saveResult = await unitOfWork.SaveAsync();

            if (saveResult.Code != HttpStatusCode.OK)
            {
                return(saveResult);
            }

            dto.Id = entity.Id;
            return(Ok(dto));
        }