public IHttpActionResult CommentReservation(GuestComment guestComment) { if (CheckRole("Guest")) { return(StatusCode(HttpStatusCode.Unauthorized)); } Reservation ress = context.Reservations.Where(x => x.ID == guestComment.ReservationID && (x.Stauts == ReservationStatus.Done || x.Stauts == ReservationStatus.Rejected) && x.Deleted != true).FirstOrDefault(); if (ress == null) { return(BadRequest("Reservation doesn't exist")); } Comment comment = new Comment(); comment.ApartmanID = ress.ApartmanID; comment.GuestID = ress.GuestID; comment.Text = guestComment.Comment; comment.Rate = guestComment.Rate; comment.Deleted = false; comment.Blocked = true; context.Comments.Add(comment); context.SaveChanges(); return(Ok("Comment added")); }
public ActionResult Create([Bind(Include = "ID,Ime,Prezime,Slika,Email,Password,Username")] Korisnik korisnik) { if (ModelState.IsValid) { db.Korisniks.Add(korisnik); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(korisnik)); }
public IHttpActionResult DeleteAmenitie(int amenitieId) { if (CheckRole("Admin")) { return(StatusCode(HttpStatusCode.Unauthorized)); } Amenitie amm = context.Amenities.Where(x => x.ID == amenitieId).FirstOrDefault(); amm.Deleted = true; //context.Amenities.Remove(amm); context.SaveChanges(); return(Ok()); }
public IHttpActionResult Register(UserBM user) { User us = new User(); us.Blocked = false; us.Name = user.Name; us.Password = user.Password; us.Role = Helper.Enums.Roles.Guest; us.UserName = user.UserName; us.Surname = user.Surname; us.Gender = (user.Gender == "Male") ? Helper.Enums.Genders.Male : Helper.Enums.Genders.Famale; context.Users.Add(us); context.SaveChanges(); return(Ok()); }
public IHttpActionResult DeleteApartmentComment(int commentId) { if (CheckRole("Admin")) { return(StatusCode(HttpStatusCode.Unauthorized)); } Comment comm = context.Comments.Where(x => x.ID == commentId).FirstOrDefault(); comm.Deleted = true; //context.Comments.Remove(comm); context.SaveChanges(); return(Ok()); }