public HttpResponseMessage GetAllFeedback(FeedbackDetailsModel model) { ResponseStatus response = new ResponseStatus(); try { var data = _repository.GetAllFeedback(model); if (data != null) { response.isSuccess = true; response.serverResponseTime = System.DateTime.Now; return(Request.CreateResponse(HttpStatusCode.OK, new { data, response })); } else { response.isSuccess = false; response.serverResponseTime = System.DateTime.Now; return(Request.CreateResponse(HttpStatusCode.BadRequest, new { response })); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Something Worng !", ex)); } }
public FeedbackDetailsModel AddFeedback(FeedbackModel model) { FeedbackDetailsModel data = null; using (nathus_rating_androidEntities context = new nathus_rating_androidEntities()) { string strPromoCode = GeneratePromoCode(); feedbackmaster user = new feedbackmaster(); //user.FeedbackId = model.FeedbackId; user.CustomerId = model.CustomerId; user.Feedback = model.Feedback; user.StoreId = model.StoreId; context.feedbackmasters.Add(user); var result = context.SaveChanges(); if (result > 0) { if (model.CustomerType == "Registered") { } else { promocodemaster p = new promocodemaster(); p.CustomerId = model.CustomerId; p.PromoCode = strPromoCode; context.promocodemasters.Add(p); context.SaveChanges(); //var promo = (from pro in context.promocodemasters // where pro.CustomerId == model.CustomerId // select pro.PromoCode).FirstOrDefault(); var customer = (from cust in context.loginmasters where cust.CustomerId == model.CustomerId select cust).FirstOrDefault(); SendSMS(customer.MobileNumber, strPromoCode); } var serv = (from s in context.loginmasters join sl in context.feedbackmasters on s.CustomerId equals sl.CustomerId where s.CustomerId == model.CustomerId select new FeedbackDetailsModel() { CustomerId = s.CustomerId, Feedback = (decimal)sl.Feedback, FeedbackId = sl.FeedbackId, StoreId = (int)sl.StoreId, MobileNumber = s.MobileNumber, CreatedOn = (DateTime)sl.CreatedOn }).FirstOrDefault(); data = serv; } } return(data); }
public IEnumerable <FeedbackDetailsModel> GetAllFeedback(FeedbackDetailsModel model) { IEnumerable <FeedbackDetailsModel> data = null; using (nathus_rating_androidEntities context = new nathus_rating_androidEntities()) { feedbackmaster user = new feedbackmaster(); var serv = (from s in context.loginmasters join sl in context.feedbackmasters on s.CustomerId equals sl.CustomerId where s.CustomerId == model.CustomerId && s.StoreId == model.StoreId orderby sl.CreatedOn ascending select new FeedbackDetailsModel() { CustomerId = s.CustomerId, Feedback = (decimal)sl.Feedback, FeedbackId = sl.FeedbackId, StoreId = (int)sl.StoreId, MobileNumber = s.MobileNumber, CreatedOn = (DateTime)sl.CreatedOn }).ToList(); data = serv; } return(data); }