Exemplo n.º 1
0
        public LoginModel UserLogin(LoginModel model)
        {
            LoginModel data = new LoginModel();

            using (qsr_androidEntities context = new qsr_androidEntities())
            {
                var check = context.loginmasters.Where(a => a.MobileNumber == model.MobileNumber && a.StoreId == model.StoreId).FirstOrDefault();
                if (check != null)
                {
                    data.CustomerId   = check.CustomerId;
                    data.StoreId      = (int)check.StoreId;
                    data.MobileNumber = check.MobileNumber;
                    data.Flag         = "Registered";
                    data.CreatedOn    = (DateTime)check.CreatedOn;
                }
                else
                {
                    loginmaster user = new loginmaster();
                    user.StoreId      = model.StoreId;
                    user.MobileNumber = model.MobileNumber;
                    context.loginmasters.Add(user);
                    var result = context.SaveChanges();
                    if (result > 0)
                    {
                        var resultData = context.loginmasters.Where(a => a.MobileNumber == model.MobileNumber && a.StoreId == model.StoreId).FirstOrDefault();
                        data.CustomerId   = resultData.CustomerId;
                        data.StoreId      = (int)resultData.StoreId;
                        data.MobileNumber = resultData.MobileNumber;
                        data.Flag         = "Not Registered";
                        data.CreatedOn    = (DateTime)resultData.CreatedOn;
                    }
                }
            }
            return(data);
        }
Exemplo n.º 2
0
        public FeedbackDetailsModel AddFeedback(FeedbackModel model)
        {
            FeedbackDetailsModel data = null;

            using (qsr_androidEntities context = new qsr_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);
        }
Exemplo n.º 3
0
        public IEnumerable <FeedbackDetailsModel> GetAllFeedback(FeedbackDetailsModel model)
        {
            IEnumerable <FeedbackDetailsModel> data = null;

            using (qsr_androidEntities context = new qsr_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 descending
                                       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);
        }