示例#1
0
        public async Task <IActionResult> Post([FromBody] PatientEditModel model)
        {
            var patient = MapModelToEntity(model);

            await _genericService.Create(patient);

            MapAndCreateConsultation(patient, model.Consultation);

            return(Ok(patient.Id));
        }
示例#2
0
        public IActionResult Create([FromBody] T entity)
        {
            if (ModelState.IsValid)
            {
                var result = _service.Create(entity);
                if (result != null)
                {
                    return(Ok(_service.Create(entity)));
                }
                return(BadRequest("Dados inválidos. Favor verificar os dados digitados."));
            }

            return(BadRequest("Dados inválidos. Favor verificar os dados digitados."));
        }
示例#3
0
        public async Task <IActionResult> LiversAdd(AddUserToFlateModel model)
        {
            string toReturn = "";
            IEnumerable <ApartmentDto> app = serviceAps.findAllWithFilter(apartment => apartment.ApartmentId == model.FlatId);

            int          a    = app.Count();
            ApartmentDto appp = app.First();
            IEnumerable <UserAppartmenDto> result = serviceUserAps.findAllWithFilter(apartment => apartment.ApartmentId == model.FlatId);

            if (appp.ApartmentSpace / (result.Count() + 1) > minMetersOnLiver)
            {
                UserAppartmenDto toSave = new UserAppartmenDto();
                toSave.ApartmentId = model.FlatId;
                toSave.UserId      = model.UserID;
                serviceUserAps.Create(toSave);
                toReturn = "saved";
                ViewData["CityWhichUserLooking"] = toReturn;
                return(View());
            }

            toReturn = "notEnogfPlace";

            ViewData["CityWhichUserLooking"] = toReturn;
            return(View());
        }
        /// <summary>
        /// POST api/{controller}
        /// </summary>
        /// <param name="item">Object to create.</param>
        /// <returns>HTTP response message indicating success or failure.</returns>
        public virtual HttpResponseMessage Post(T item)
        {
            if (!authService.VerifyAuthenticationHeader(Request.Headers.Authorization))
            {
                throw new HttpResponseException(HttpStatusCode.Unauthorized);
            }

            HttpResponseMessage responseMessage = null;

            try
            {
                PK id      = service.Create(item);
                T  newItem = service.Retrieve(id);
                responseMessage = Request.CreateResponse <T>(HttpStatusCode.Created, newItem);
                //string uri = Url.Link("DefaultApi", new { id = id });
                //responseMessage.Headers.Location = new Uri(uri);
            }
            catch (Exception e)
            {
                string errorMessage = "The POST request failed for " + typeof(T).Name + " due to the following error:\n " + e.Message;
                responseMessage = Request.CreateErrorResponse(HttpStatusCode.BadRequest, errorMessage);
            }

            return(responseMessage);
        }
示例#5
0
        private async Task CreateOrUpdate()
        {
            IsBusy    = true;
            AuthorDTO = new AuthorDTO
            {
                Name        = Name,
                LastName    = LastName,
                Phone       = Phone,
                Email       = Email,
                IdGender    = IdGender,
                NumberBooks = NumberBooks,
                IdCity      = IdCity,
                IdState     = IdState,
                IdCountry   = IdCountry
            };
            try
            {
                if (AuthorDTO != null)
                {
                    if (ValidateFields())
                    {
                        var query = await _authorSvc.Create(AuthorDTO, true, "api/Authors/Create");

                        if (query != null)
                        {
                            Msj = "Datos registrados con éxito";
                            await GetAll();

                            ClearFields();
                        }
                        else
                        {
                            Msj = "Error al guardar los datos, por favor verifique que esté todo diligenciado";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Msj = ex.Message;
            }
            finally
            {
                IsBusy = false;
            }
        }
 public ActionResult <ResponseVM> AddTicket([FromBody] TicketVM ticketVM)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("Something went wrong"));
     }
     return(ticketService.Create(ticketVM));
 }
示例#7
0
 public ActionResult <ResponseVM> Create([FromBody] BookVM bookVM)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("Something went wrong!"));
     }
     return(bookService.Create(bookVM));
 }
示例#8
0
 public ActionResult <ResponseVM> CreateEmployee([FromBody] EmployeeVM employeeVM)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("Something went wrong"));
     }
     return(employeeService.Create(employeeVM));
 }
示例#9
0
 public ActionResult <ResponseVM> Create([FromBody] AuthorVM authorVM)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("Something went wrong"));
     }
     return(authorService.Create(authorVM));
 }
示例#10
0
        private async Task CreateOrUpdate()
        {
            IsBusy = true;
            BookDTO book = new BookDTO
            {
                Name        = NameBook,
                WriteDate   = WriteDate,
                LaunchDate  = LaunchDate,
                Price       = Price,
                IdAuthor    = IdAuthor,
                IdEditorial = IdEditorial,
                Remarks     = Remarks
            };

            try
            {
                if (book != null)
                {
                    if (ValidateFields())
                    {
                        var query = await _bookSvc.Create(book, true, "api/Books/Create");

                        if (query != null)
                        {
                            Msj = "Datos registrados con éxito";
                            await GetAll();

                            ClearFields();
                        }
                        else
                        {
                            Msj = "Error al guardar los datos, por favor verifique que esté todo diligenciado";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Msj = ex.Message;
            }
            finally
            {
                IsBusy = false;
            }
        }
 public ActionResult <ResponseVM> Create
     ([FromBody] OfficeVM officeVM)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("something went wrong"));
     }
     return(officeService.Create(officeVM));
 }
示例#12
0
 public ActionResult <ResponseVM> Create
     ([FromBody] CategoryListVM categorylistVM)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("something went wrong"));
     }
     return(categorylistService.Create(categorylistVM));
 }
 public ResultHelper Post([FromBody] AdvertStatus advertStatus)
 {
     if (advertStatus == null)
     {
         return(new ResultHelper(true, advertStatus.AdvertStatusID, ResultHelper.UnSuccessMessage));
     }
     advertStatusService.Create(advertStatus);
     return(new ResultHelper(true, advertStatus.AdvertStatusID, ResultHelper.SuccessMessage));
 }
示例#14
0
 public ResultHelper Post([FromBody] Photo Photo)
 {
     if (Photo == null)
     {
         return(new ResultHelper(true, Photo.PhotoID, ResultHelper.UnSuccessMessage));
     }
     photoService.Create(Photo);
     return(new ResultHelper(true, Photo.PhotoID, ResultHelper.SuccessMessage));
 }
 public ResultHelper Post([FromBody] Complaint complaint)
 {
     if (complaint == null)
     {
         return(new ResultHelper(true, complaint.ComplaintID, ResultHelper.UnSuccessMessage));
     }
     complaintService.Create(complaint);
     return(new ResultHelper(true, complaint.ComplaintID, ResultHelper.UnSuccessMessage));
 }
示例#16
0
 public ResultHelper Post([FromBody] Advert advert)
 {
     if (advert == null)
     {
         return(new ResultHelper(true, advert.AdvertID, ResultHelper.UnSuccessMessage));
     }
     advertService.Create(advert);
     return(new ResultHelper(true, advert.AdvertID, ResultHelper.SuccessMessage));
 }
 public ResultHelper Post([FromBody] SharedPhoto SharedPhoto)
 {
     if (SharedPhoto == null)
     {
         return(new ResultHelper(true, SharedPhoto.SharedPhotoID, ResultHelper.UnSuccessMessage));
     }
     sharedPhotoService.Create(SharedPhoto);
     return(new ResultHelper(true, SharedPhoto.SharedPhotoID, ResultHelper.SuccessMessage));
 }
示例#18
0
 public ResultHelper Post([FromBody] Univercity Univercity)
 {
     if (Univercity == null)
     {
         return(new ResultHelper(true, Univercity.UnivercityID, ResultHelper.UnSuccessMessage));
     }
     univercityService.Create(Univercity);
     return(new ResultHelper(true, Univercity.UnivercityID, ResultHelper.SuccessMessage));
 }
 public ResultHelper Post([FromBody] UserPassword UserPassword)
 {
     if (UserPassword == null)
     {
         return(new ResultHelper(true, UserPassword.UserPasswordID, ResultHelper.UnSuccessMessage));
     }
     userPasswordService.Create(UserPassword);
     return(new ResultHelper(true, UserPassword.UserPasswordID, ResultHelper.SuccessMessage));
 }
示例#20
0
 public ResultHelper Post([FromBody] AdvertSeenUser advertSeenUser)
 {
     if (advertSeenUser == null)
     {
         return(new ResultHelper(true, advertSeenUser.AdvertSeenUserID, ResultHelper.UnSuccessMessage));
     }
     advertseenuserservice.Create(advertSeenUser);
     return(new ResultHelper(true, advertSeenUser.AdvertSeenUserID, ResultHelper.SuccessMessage));
 }
 public ResultHelper Post([FromBody] UserStarAndComment UserStarAndComment)
 {
     if (UserStarAndComment == null)
     {
         return(new ResultHelper(true, UserStarAndComment.UserStarAndCommentID, ResultHelper.UnSuccessMessage));
     }
     userStarAndCommentService.Create(UserStarAndComment);
     return(new ResultHelper(true, UserStarAndComment.UserStarAndCommentID, ResultHelper.SuccessMessage));
 }
 public ResultHelper Post([FromBody] RegisterTemp RegisterTemp)
 {
     if (RegisterTemp == null)
     {
         return(new ResultHelper(true, RegisterTemp.RegisterTempID, ResultHelper.UnSuccessMessage));
     }
     registerTempService.Create(RegisterTemp);
     return(new ResultHelper(true, RegisterTemp.RegisterTempID, ResultHelper.SuccessMessage));
 }
示例#23
0
 public ResultHelper Post([FromBody] NotificationType notificationType)
 {
     if (notificationType == null)
     {
         return(new ResultHelper(true, notificationType.NotificationTypeID, ResultHelper.UnSuccessMessage));
     }
     notificationTypeService.Create(notificationType);
     return(new ResultHelper(true, notificationType.NotificationTypeID, ResultHelper.SuccessMessage));
 }
示例#24
0
 public ResultHelper Post([FromBody] Message Message)
 {
     if (Message == null)
     {
         return(new ResultHelper(true, Message.MessageID, ResultHelper.UnSuccessMessage));
     }
     messageService.Create(Message);
     return(new ResultHelper(true, Message.MessageID, ResultHelper.SuccessMessage));
 }
示例#25
0
        public async Task <IActionResult> Post([FromBody] NamedModel model)
        {
            var diagnostic = new Diagnostic {
                Name = model.Name
            };
            var id = await _genericService.Create(diagnostic);

            return(Ok(id));
        }
示例#26
0
 public ResultHelper Post([FromBody] Contact Contact)
 {
     if (Contact == null)
     {
         return(new ResultHelper(true, Contact.ContactID, ResultHelper.UnSuccessMessage));
     }
     contactService.Create(Contact);
     return(new ResultHelper(true, Contact.ContactID, ResultHelper.UnSuccessMessage));
 }
示例#27
0
 public ResultHelper Post([FromBody] Notification notification)
 {
     if (notification == null)
     {
         return(new ResultHelper(true, notification.NotificationID, ResultHelper.UnSuccessMessage));
     }
     notificationService.Create(notification);
     return(new ResultHelper(true, notification.NotificationID, ResultHelper.SuccessMessage));
 }
示例#28
0
 public ResultHelper Post([FromBody] FavAdvert favAdvert)
 {
     if (favAdvert == null)
     {
         return(new ResultHelper(true, favAdvert.FavAdvertID, ResultHelper.UnSuccessMessage));
     }
     favAdvertService.Create(favAdvert);
     return(new ResultHelper(true, favAdvert.FavAdvertID, ResultHelper.UnSuccessMessage));
 }
示例#29
0
 public ResultHelper Post([FromBody] UserTime UserTime)
 {
     if (UserTime == null)
     {
         return(new ResultHelper(true, UserTime.UserTimeID, ResultHelper.UnSuccessMessage));
     }
     userTimeService.Create(UserTime);
     return(new ResultHelper(true, UserTime.UserTimeID, ResultHelper.SuccessMessage));
 }
示例#30
0
 public ResultHelper Post([FromBody] OldPassword OldPassword)
 {
     if (OldPassword == null)
     {
         return(new ResultHelper(true, OldPassword.OldPasswordID, ResultHelper.UnSuccessMessage));
     }
     oldPasswordService.Create(OldPassword);
     return(new ResultHelper(true, OldPassword.OldPasswordID, ResultHelper.SuccessMessage));
 }