/// <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);
            }
        }
コード例 #2
0
        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);
        }