public IHttpActionResult Post(Users value) { var Id = int.Parse(dbContext.Users.Max(z => z.UsersId)) + 1; if (!dbContext.Users.Any(x => x.Email.Equals(value.Email))) { Users Nuser = new Users(); Nuser.UsersId = Id.ToString(); Nuser.Names = value.Names; Nuser.Passwords = value.Passwords; Nuser.Email = value.Email; Nuser.Department = value.Department; Nuser.StartDate = value.StartDate; Nuser.Nationality = value.Nationality; Nuser.Position = value.Position; Nuser.Profilepic = value.Profilepic; try { dbContext.Add(Nuser); dbContext.SaveChanges(); string message = "Registered"; var example = new messageclass { Message = message }; return(Ok(example)); } catch (Exception ex) { string message = "Submit Failed" + ex.Message; var example = new messageclass { Message = message }; return(Ok(example)); } } else { string message = "The Email has been used"; var example = new messageclass { Message = message }; return(Ok(example)); } }
public IHttpActionResult Post(Cancellation value) { var Id = (dbContext.Cancellation.Max(z => z.CancellationId)) + 1; if (!dbContext.Cancellation.Any(cancel => cancel.BookingId.Equals(value.BookingId) && cancel.Status.Equals("New"))) { Cancellation cancellation = new Cancellation(); cancellation.CancellationId = Id; cancellation.BookingId = value.BookingId; cancellation.Reason = value.Reason; cancellation.Status = "New"; try { dbContext.Add(cancellation); dbContext.SaveChanges(); string message = "Submit Successfully"; var example = new messageclass { Message = message }; return(Ok(example)); } catch (Exception ex) { string message = "Submit Failed" + ex.Message; var example = new messageclass { Message = message }; return(Ok(example)); } } else { string message = "You have made a cancellation for this Booking already, please wait for the approval"; var example = new messageclass { Message = message }; return(Ok(example)); } }