public List <Feedback> GetFeedback() { var entities = new FoodfeedbackDBContext(); var feedback = entities.Feedback.ToList(); return(feedback); }
public bool CheckIfEmployeeIdAlreadyExists(RegistrationDTO registrationDTO) { var entities = new FoodfeedbackDBContext(); var CheckEmployeeIdresult = entities.Users.Where(x => x.EmpId == registrationDTO.EmpId).Any(); return(CheckEmployeeIdresult); }
/// <summary> /// Register the user details /// </summary> /// <param name="registrationDTO"></param> /// <returns> /// true if user register /// </returns> public int RegisterUser([FromBody] RegistrationDTO registrationDTO) { //string exists = ""; var entities = new FoodfeedbackDBContext(); var RegisteredUserDetails = new Users() { Email = registrationDTO.Email, Password = registrationDTO.Password, EmpId = registrationDTO.EmpId, Username = registrationDTO.Username, }; var UserExists = CheckIfEmailAlreadyExists(registrationDTO); var EmployeeIdExists = CheckIfEmployeeIdAlreadyExists(registrationDTO); if (UserExists == true) { return(2); } else if (EmployeeIdExists == true) { return(0); } else { entities.Users.Add(RegisteredUserDetails); entities.SaveChanges(); return(1); } }
public int CheckIfUserIsAdmin(string email) { var entities = new FoodfeedbackDBContext(); var CheckAdminUserResult = entities.Users.Where(x => x.Email == email).Select(r => r.IsAdmin).FirstOrDefault(); if (CheckAdminUserResult == 0) { return(0); } else { return(1); } }
public bool AddFeedback([FromBody] AddFeedbackDTO addFeedbackDTO) { var entities = new FoodfeedbackDBContext(); var FeedbackDetails = new Feedback() { SelectDate = addFeedbackDTO.SelectDate, TypeOfMeal = addFeedbackDTO.TypeOfMeal, Rating = addFeedbackDTO.Rating, Comments = addFeedbackDTO.Comments, Email = addFeedbackDTO.Email }; entities.Feedback.Add(FeedbackDetails); entities.SaveChanges(); return(true); }
/// <summary> /// checks if the given user exist or not /// </summary> /// <param name="userDTO"></param> /// <returns> /// true if user exists /// false if user does not exist /// </returns> public int CheckIfUserExists([FromBody] UserDTO userDTO) { var entities = new FoodfeedbackDBContext(); int UserResult; var loginresult = entities.Users.Where(x => x.Email == userDTO.Email && x.Password == userDTO.Password).FirstOrDefault(); if (loginresult != null) { UserResult = CheckIfUserIsAdmin(userDTO.Email); } else { UserResult = 2; } return(UserResult); }
/// <summary> /// Check the rating and calculate average rating /// </summary> /// <param name="viewratingDTO"></param> /// <returns> /// average rating value /// </returns> public double GetAverageRating([FromBody] ViewRatingDTO viewratingDTO) { var entities = new FoodfeedbackDBContext(); var viewratingresult = entities.Feedback.Where(r => r.SelectDate == viewratingDTO.SelectDate && r.TypeOfMeal == viewratingDTO.TypeOfMeal) .GroupBy(g => g.TypeOfMeal, r => r.Rating) .Select(g => new ResponseDTO() { Average_Rating = g.Average() }).FirstOrDefault(); if (viewratingresult == null) { return(0); } else { var average = Convert.ToDouble(viewratingresult.Average_Rating); return(average); } }
public Loginservice(FoodfeedbackDBContext foodfeedbackDBContext) { _foodfeedbackDBContext = foodfeedbackDBContext; }
public AddFeedbackService(FoodfeedbackDBContext foodfeedbackDBContext) { _foodfeedbackDBContext = foodfeedbackDBContext; }
public ViewRatingService(FoodfeedbackDBContext foodfeedbackDBContext) { _foodfeedbackDBContext = foodfeedbackDBContext; }
public RegistrationService(FoodfeedbackDBContext foodfeedbackDBContext) { _foodfeedbackDBContext = foodfeedbackDBContext; }