public string Get(int id)
 {
     try
     {
         var item = _complaintService.FindById(id);
         return(JsonConvert.SerializeObject(ApiResponseUtility.CreateSuccessResponse(item)));
     }
     catch (Exception ex)
     {
         return(JsonConvert.SerializeObject(ApiResponseUtility.CreateErrorResponse(ex)));
     }
 }
Exemple #2
0
        public string Login(User user)
        {
            try
            {
                bool isLoggedIn = _accountService.Login(user);
                if (isLoggedIn)
                {
                    return(JsonConvert.SerializeObject(ApiResponseUtility.CreateSuccessResponse("Login Sucessful", isLoggedIn)));
                }

                return(JsonConvert.SerializeObject(ApiResponseUtility.CreateSuccessResponse("Username or Password Incorrect", isLoggedIn)));
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(ApiResponseUtility.CreateErrorResponse(ex)));
            }
        }
        public string Post(ComplaintModel complaint)
        {
            try
            {
                complaint.ComplaintDate = DateTime.Now;
                bool isCreated = _complaintService.Create(complaint);
                if (isCreated)
                {
                    return(JsonConvert.SerializeObject(ApiResponseUtility.CreateSuccessResponse("Complaint Logged", isCreated)));
                }

                return(JsonConvert.SerializeObject(ApiResponseUtility.CreateSuccessResponse("Complaint Logged Unsucessful", isCreated)));
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(ApiResponseUtility.CreateErrorResponse(ex)));
            }
        }