Пример #1
0
        public MenuMasterModel AddNewMenu(MenuMasterModel model)
        {
            //ResponseStatus respponse = new ResponseStatus();
            MenuMasterModel data = new MenuMasterModel();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                var me = context.menumasters.Find(model.MenuId);
                if (me != null)
                {
                    me.MenuName  = model.MenuName;
                    me.MenuPrice = model.MenuPrice;
                    me.StoreId   = model.StoreId;
                    var result = context.SaveChanges();
                    if (result > 0)
                    {
                        data.MenuId = me.MenuId;
                    }
                }
                else
                {
                    menumaster m = new menumaster();
                    m.MenuName  = model.MenuName;
                    m.MenuPrice = model.MenuPrice;
                    m.StoreId   = model.StoreId;
                    context.menumasters.Add(m);
                    var result = context.SaveChanges();
                    if (result > 0)
                    {
                        data.MenuId = m.MenuId;
                    }
                }
            }
            return(data);
        }
        public StoreModel AddNewStore(StoreModel model)
        {
            StoreModel data = new StoreModel();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                var st = context.storemasters.Find(model.StoreId);
                if (st != null)
                {
                    st.LocalityId       = model.LocalityId;
                    st.StoreName        = model.StoreName;
                    st.StorePhoneNumber = model.StorePhoneNumber;
                    st.StoreEmailId     = model.StoreEmailId;
                    st.StoreAddress     = model.StoreAddress;
                    st.OpeningTime      = model.OpeningTime;
                    st.ClosingTime      = model.ClosingTime;
                    //s.StoreStatus = model.StoreStatus;
                    //if (model.StoreStatus)
                    //{
                    //st.StoreStatus = "Y";
                    //}
                    //else
                    //{
                    //    st.StoreStatus = "N";
                    //}
                    var result = context.SaveChanges();
                    if (result > 0)
                    {
                        data.StoreId = st.StoreId;
                    }
                }
                else
                {
                    storemaster s = new storemaster();
                    s.LocalityId       = model.LocalityId;
                    s.StoreName        = model.StoreName;
                    s.StorePhoneNumber = model.StorePhoneNumber;
                    s.StoreEmailId     = model.StoreEmailId;
                    s.StoreAddress     = model.StoreAddress;
                    s.OpeningTime      = model.OpeningTime;
                    s.ClosingTime      = model.ClosingTime;
                    //s.StoreStatus = model.StoreStatus;
                    //if (model.StoreStatus)
                    //{
                    s.StoreStatus = "Y";
                    //}
                    //else
                    //{
                    //    s.StoreStatus = "N";
                    //}
                    context.storemasters.Add(s);
                    var result = context.SaveChanges();
                    if (result > 0)
                    {
                        data.StoreId = s.StoreId;
                    }
                }
            }
            return(data);
        }
        public IEnumerable <StoreModel> RemoveStore(int id)
        {
            //ResponseStatus response = new ResponseStatus();
            List <StoreModel> data = new List <StoreModel>();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                context.storemasters.Remove(context.storemasters.Where(d => d.StoreId == id).First());
                var result = context.SaveChanges();
                if (result > 0)
                {
                    data = (from s in context.storemasters
                            orderby s.StoreName
                            select new StoreModel()
                    {
                        StoreId = s.StoreId,
                        StoreName = s.StoreName,
                        StoreEmailId = s.StoreEmailId,
                        StorePhoneNumber = s.StorePhoneNumber,
                        StoreAddress = s.StoreAddress,
                        OpeningTime = (DateTime)s.OpeningTime,
                        ClosingTime = (DateTime)s.ClosingTime,
                        StoreStatus = s.StoreStatus == "Y" ? true : false,
                        StorePicturesUrl = "http://103.233.79.234/Data/EverGreen_Android/StorePictures/" + s.StoreId + ".jpg",
                    }).ToList();
                }
            }
            return(data);
        }
Пример #4
0
        public ResponseStatus Login(string phoneNumber, int loginId)
        {
            ResponseStatus response = new ResponseStatus();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                registrationmaster u = new registrationmaster();
                u.PhoneNumber = phoneNumber;
                u.LoginID     = loginId;
                u.OTP         = Convert.ToString(SendOTP(u.PhoneNumber));
                var data = context.registrationmasters.Where(x => x.LoginID == u.LoginID && x.PhoneNumber == u.PhoneNumber).FirstOrDefault();
                if (data != null)
                {
                    context.registrationmasters.Where(p => p.LoginID == u.LoginID && p.PhoneNumber == u.PhoneNumber).ToList().ForEach(x => x.OTP = u.OTP);
                }
                var result = context.SaveChanges();
                if (result > 0)
                {
                    response.isSuccess          = true;
                    response.serverResponseTime = System.DateTime.Now;
                }
                else
                {
                    response.isSuccess          = false;
                    response.serverResponseTime = System.DateTime.Now;
                }
            }
            return(response);
        }
        public StoreModel StoreClose(int id)
        {
            //ResponseStatus respponse = new ResponseStatus();
            StoreModel data = new StoreModel();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                var result = context.storemasters.Where(w => w.StoreId == id);
                foreach (var item in result)
                {
                    item.StoreStatus = "N";
                }
                context.SaveChanges();
                data = (from s in context.storemasters
                        orderby s.StoreName
                        where s.StoreId == id
                        select new StoreModel()
                {
                    StoreId = s.StoreId,
                    StoreName = s.StoreName,
                    StoreEmailId = s.StoreEmailId,
                    StorePhoneNumber = s.StorePhoneNumber,
                    StoreAddress = s.StoreAddress,
                    OpeningTime = (DateTime)s.OpeningTime,
                    ClosingTime = (DateTime)s.ClosingTime,
                    StoreStatus = s.StoreStatus == "Y" ? true : false,
                    StorePicturesUrl = "http://103.233.79.234/Data/EverGreen_Android/StorePictures/" + s.StoreId + ".jpg",
                }).FirstOrDefault();
            }
            return(data);
        }
Пример #6
0
        public AddressModel UpdateAddress(AddressModel model)
        {
            AddressModel data = new AddressModel();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                addressmaster a = new addressmaster();
                a.AddressId            = model.AddressId;
                a.CompleteAddress      = model.CompleteAddress;
                a.ZipCode              = model.ZipCode;
                a.LandMark             = model.LandMark;
                a.LoginID              = model.LoginID;
                a.PhoneNumber          = model.PhoneNumber;
                a.LocalityId           = model.LocalityId;
                context.Entry(a).State = System.Data.Entity.EntityState.Modified;
                var result = context.SaveChanges();
                if (result > 0)
                {
                    var addressdata = context.addressmasters.Where(x => x.AddressId == model.AddressId).FirstOrDefault();
                    if (addressdata != null)
                    {
                        data.AddressId       = addressdata.AddressId;
                        data.CompleteAddress = addressdata.CompleteAddress;
                        data.ZipCode         = addressdata.ZipCode;
                        data.LandMark        = addressdata.LandMark;
                        data.LoginID         = (int)addressdata.LoginID;
                        data.PhoneNumber     = addressdata.PhoneNumber;
                        data.LocalityId      = (int)addressdata.LocalityId;
                    }
                }
            }
            return(data);
        }
Пример #7
0
        public AddressModel AddNewAddress(AddressModel model)
        {
            AddressModel data = new AddressModel();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                addressmaster a = new addressmaster();
                a.CompleteAddress = model.CompleteAddress;
                a.ZipCode         = model.ZipCode;
                a.LandMark        = model.LandMark;
                a.LoginID         = model.LoginID;
                a.PhoneNumber     = model.PhoneNumber;
                a.LocalityId      = model.LocalityId;
                context.addressmasters.Add(a);
                var result = context.SaveChanges();
                if (result > 0)
                {
                    var addressdata = context.addressmasters.Where(z => z.LoginID == model.LoginID).OrderByDescending(x => x.AddressId).FirstOrDefault();
                    if (addressdata != null)
                    {
                        data.AddressId       = addressdata.AddressId;
                        data.CompleteAddress = addressdata.CompleteAddress;
                        data.ZipCode         = addressdata.ZipCode;
                        data.LandMark        = addressdata.LandMark;
                        data.LoginID         = (int)addressdata.LoginID;
                        data.PhoneNumber     = addressdata.PhoneNumber;
                        data.LocalityId      = (int)addressdata.LocalityId;
                    }
                }
            }
            return(data);
        }
Пример #8
0
        public UserModel UpdateProfile(UserModel user)
        {
            UserModel resultdata = new UserModel();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                registrationmaster u = new registrationmaster();
                u.LoginID              = user.LoginID;
                u.PhoneNumber          = user.PhoneNumber;
                u.Name                 = user.Name;
                u.EmailID              = user.EmailID;
                u.Role                 = user.Role;
                context.Entry(u).State = System.Data.Entity.EntityState.Modified;
                var result = context.SaveChanges();
                if (result > 0)
                {
                    var data = context.registrationmasters.Where(x => x.LoginID == user.LoginID).First();
                    if (data != null)
                    {
                        UserModel users = new UserModel();
                        users.LoginID           = Convert.ToInt32(data.LoginID);
                        users.Name              = data.Name;
                        users.PhoneNumber       = data.PhoneNumber;
                        users.Otp               = Convert.ToInt32(data.OTP);
                        users.Role              = Convert.ToInt32(data.Role);
                        users.EmailID           = data.EmailID;
                        users.ProfilePictureUrl = "http://103.233.79.234/Data/EverGreen_Android/EverGreenProfilePicture/" + user.LoginID + ".jpeg";
                        resultdata              = users;
                    }
                }
            }
            return(resultdata);
        }
        public IEnumerable <LocalitiesModel> RemoveLocality(int id)
        {
            ResponseStatus         response = new ResponseStatus();
            List <LocalitiesModel> data     = new List <LocalitiesModel>();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                context.localitymasters.Remove(context.localitymasters.Where(d => d.LocalityId == id).First());
                var result = context.SaveChanges();
                if (result > 0)
                {
                    data = (from lo in context.localitymasters
                            join st in context.storemasters on lo.StoreId1 equals st.StoreId into j1
                            from j2 in j1.DefaultIfEmpty()
                            join st1 in context.storemasters on lo.StoreId2 equals st1.StoreId into j3
                            from j4 in j3.DefaultIfEmpty()
                            join st2 in context.storemasters on lo.StoreId3 equals st2.StoreId into j5
                            from j6 in j5.DefaultIfEmpty()
                            orderby lo.CreatedOn descending
                            //where lo.LocalityId == l.LocalityId
                            select new LocalitiesModel()
                    {
                        LocalityId = lo.LocalityId,
                        LocalityName = lo.LocalityName,
                        StoreName = j2.StoreName,
                        StoreName1 = j4.StoreName,
                        StoreName2 = j6.StoreName
                    }).ToList();
                }
            }
            return(data);
        }
Пример #10
0
        public PaymentModel PaymentConfirmforCOD(PaymentModel model)
        {
            PaymentModel data = new PaymentModel();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                transactionmaster t = new transactionmaster();
                t.OrderNumber = model.OrderNumber;
                t.LoginId     = model.LoginId;
                t.StoreId     = model.StoreId;
                t.PaymentMode = model.PaymentMode;
                context.transactionmasters.Add(t);
                var result = context.SaveChanges();
                if (result > 0)
                {
                    var payment = (from o in context.ordermasters
                                   join tr in context.transactionmasters on o.OrderNumber equals tr.OrderNumber into j1
                                   from j2 in j1.DefaultIfEmpty()
                                   where o.OrderNumber == model.OrderNumber
                                   select new PaymentModel()
                    {
                        Id = j2.Id,
                        OrderNumber = j2.OrderNumber,
                        TotalAmount = (decimal)o.TotalPrice,
                        PaymentMode = j2.PaymentMode
                    }).FirstOrDefault();
                    data = payment;
                }
                if (data.Id > 0)
                {
                    SendSmsAndEmail(model.OrderNumber);
                }
                return(data);
            }
        }
Пример #11
0
        public ResponseStatus RemoveFavouriteStoreByUser(int loginid)
        {
            ResponseStatus response = new ResponseStatus();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                if (loginid > 0)
                {
                    var data = context.registrationmasters.FirstOrDefault(w => w.LoginID == loginid);
                    if (data != null)
                    {
                        data.FavouriteStoreId = 0;
                        context.SaveChanges();
                        response.isSuccess          = true;
                        response.serverResponseTime = System.DateTime.Now;
                    }
                    else
                    {
                        response.isSuccess          = false;
                        response.serverResponseTime = System.DateTime.Now;
                    }
                }
            }
            return(response);
        }
Пример #12
0
        public IEnumerable <MenuMasterModel> RemoveMenu(int id)
        {
            //ResponseStatus response = new ResponseStatus();
            List <MenuMasterModel> data = new List <MenuMasterModel>();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                context.menumasters.Remove(context.menumasters.Where(d => d.MenuId == id).First());
                var result = context.SaveChanges();
                if (result > 0)
                {
                    data = (from m in context.menumasters
                            join s in context.storemasters on m.StoreId equals s.StoreId into j1
                            from j2 in j1.DefaultIfEmpty()
                            orderby m.CreatedOn descending
                            select new MenuMasterModel()
                    {
                        MenuId = m.MenuId,
                        MenuName = m.MenuName,
                        MenuPrice = (decimal)m.MenuPrice,
                        StoreName = j2.StoreName
                    }).ToList();
                }
            }
            return(data);
        }
        public LocalitiesModel AddNewLocalityName(LocalitiesModel model)
        {
            //ResponseStatus respponse = new ResponseStatus();
            LocalitiesModel data = new LocalitiesModel();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                var lc = context.localitymasters.Find(model.LocalityId);
                if (lc != null)
                {
                    lc.LocalityName = model.LocalityName;
                    lc.StoreId1     = model.StoreId;
                    lc.StoreId2     = model.StoreId1;
                    lc.StoreId3     = model.StoreId2;
                    var result = context.SaveChanges();
                    if (result > 0)
                    {
                        data.LocalityId   = lc.LocalityId;
                        data.LocalityName = lc.LocalityName;
                    }
                }
                else
                {
                    localitymaster l = new localitymaster();
                    l.LocalityName = model.LocalityName;
                    l.StoreId1     = model.StoreId;
                    l.StoreId2     = model.StoreId1;
                    l.StoreId3     = model.StoreId2;
                    context.localitymasters.Add(l);
                    var result = context.SaveChanges();
                    if (result > 0)
                    {
                        data.LocalityId   = l.LocalityId;
                        data.LocalityName = l.LocalityName;
                    }
                }
            }
            return(data);
        }
Пример #14
0
        public UserModel Login(string phonenumber, string deviceid)
        {
            //ResponseStatus response = new ResponseStatus();
            UserModel user = new UserModel();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                registrationmaster u = new registrationmaster();
                var data             = context.registrationmasters.Where(x => x.PhoneNumber == phonenumber).FirstOrDefault();
                if (data == null)
                {
                    u.PhoneNumber = phonenumber;
                    u.OTP         = Convert.ToString(SendOTP(u.PhoneNumber));
                    u.DeviceId    = deviceid;
                    context.registrationmasters.Add(u);
                    //foreach (var item in data)
                    //{
                    //    item.OTP = u.OTP;
                    //    item.DeviceId = u.DeviceId;
                    //}
                    //context.registrationmasters.Where(p => p.PhoneNumber == u.PhoneNumber).ToList()
                    //    .ForEach(x => x.OTP = u.OTP);
                }
                else
                {
                    var userdata = context.registrationmasters.Where(x => x.PhoneNumber == phonenumber);
                    foreach (var item in userdata)
                    {
                        item.OTP      = Convert.ToString(SendOTP(phonenumber));
                        item.DeviceId = deviceid;
                    }
                }
                var result = context.SaveChanges();
                if (result > 0)
                {
                    var userdata = context.registrationmasters.Where(x => x.PhoneNumber == phonenumber).FirstOrDefault();
                    if (userdata != null)
                    {
                        user.LoginID     = Convert.ToInt32(userdata.LoginID);
                        user.Name        = userdata.Name;
                        user.PhoneNumber = userdata.PhoneNumber;
                        user.Otp         = Convert.ToInt32(userdata.OTP);
                        user.Role        = Convert.ToInt32(userdata.Role);
                        user.EmailID     = userdata.EmailID;

                        user.ProfilePictureUrl = "http://103.233.79.234/Data/EverGreen_Android/EverGreenProfilePicture/" + userdata.LoginID + ".jpeg";
                    }
                }
            }
            return(user);
        }
Пример #15
0
        public CategoryModel AddNewCategory(CategoryModel model)
        {
            //ResponseStatus respponse = new ResponseStatus();
            CategoryModel data = new CategoryModel();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                var ca = context.categorymasters.Find(model.CategoryId);
                if (ca != null)
                {
                    ca.CategoryName        = model.CategoryName;
                    ca.MenuId              = model.MenuId;
                    ca.StoreId             = model.StoreId;
                    ca.CategoryDescription = model.CategoryDescription;
                    var result = context.SaveChanges();
                    if (result > 0)
                    {
                        data.CategoryId = ca.CategoryId;
                    }
                }
                else
                {
                    categorymaster c = new categorymaster();
                    c.CategoryName        = model.CategoryName;
                    c.MenuId              = model.MenuId;
                    c.StoreId             = model.StoreId;
                    c.CategoryDescription = model.CategoryDescription;
                    context.categorymasters.Add(c);
                    var result = context.SaveChanges();
                    if (result > 0)
                    {
                        data.CategoryId = c.CategoryId;
                    }
                }
            }
            return(data);
        }
Пример #16
0
        public IEnumerable <MenuSetUpMasterModel> SetupMenu(MenuSetupModel model)
        {
            ResponseStatus response = new ResponseStatus();
            List <MenuSetUpMasterModel> resultdata = new List <MenuSetUpMasterModel>();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                var data = context.menusetupmasters.Where(w => w.menuid == model.MenuId && w.categoryid == model.CategoryId && w.Productid == model.ProductId).FirstOrDefault();
                if (data != null)
                {
                }
                else
                {
                    menusetupmaster m = new menusetupmaster();
                    m.menuid     = model.MenuId;
                    m.categoryid = model.CategoryId;
                    m.Productid  = model.ProductId;
                    context.menusetupmasters.Add(m);
                    var result = context.SaveChanges();
                    if (result > 0)
                    {
                        resultdata = (from ms in context.menusetupmasters
                                      join me in context.menumasters on ms.menuid equals me.MenuId into j1
                                      from j2 in j1.DefaultIfEmpty()
                                      join cat in context.categorymasters on ms.categoryid equals cat.CategoryId into j3
                                      from j4 in j3.DefaultIfEmpty()
                                      join pro in context.productmasters on ms.Productid equals pro.ProductId into j5
                                      from j6 in j5.DefaultIfEmpty()
                                      orderby ms.createdon descending
                                      select new MenuSetUpMasterModel()
                        {
                            id = ms.id,
                            MenuName = j2.MenuName,
                            CategoryName = j4.CategoryName,
                            ProductName = j6.ProductName,
                            CreatedOn = (DateTime)ms.createdon
                        }).ToList();
                    }
                }
            }
            return(resultdata);
        }
        public IEnumerable <ProductModel> ProductLockOff(int id)
        {
            ResponseStatus      response   = new ResponseStatus();
            List <ProductModel> resultdata = new List <ProductModel>();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                var result = context.productmasters.Where(w => w.ProductId == id);
                foreach (var item in result)
                {
                    item.Lock = "N";
                }
                var saved = context.SaveChanges();

                if (saved > 0)
                {
                    var data = (from p in context.productmasters
                                join c in context.categorymasters on p.CategoryId equals c.CategoryId into j1
                                from j2 in j1.DefaultIfEmpty()
                                orderby p.CreatedOn
                                select new ProductModel()
                    {
                        ProductId = p.ProductId,
                        ProductName = p.ProductName,
                        CategoryId = (int)p.CategoryId,
                        CategoryName = j2.CategoryName,
                        UnitPrice = (decimal)p.UnitPrice,
                        GST = (decimal)p.GST,
                        Discount = (decimal)p.Discount,
                        TaxType = p.TaxType,
                        UOM = p.UOM,
                        HSN = p.HSN,
                        SweetsReset = p.SweetsReset,
                        ProductDetails = p.ProductDetails,
                        Lock = p.Lock == "Y" ? true : false,
                        ProductPicturesUrl = "http://103.233.79.234/Data/EverGreen_Android/ProductPictures/" + p.ProductId + ".jpg",
                    }).ToList();
                    resultdata = data;
                }
            }
            return(resultdata);
        }
Пример #18
0
        public ResponseStatus DeleteAddress(int addressid)
        {
            ResponseStatus response = new ResponseStatus();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                addressmaster address = new addressmaster();
                address = context.addressmasters.Find(addressid);
                if (address != null)
                {
                    context.addressmasters.Remove(address);
                    context.SaveChanges();
                    response.isSuccess          = true;
                    response.serverResponseTime = System.DateTime.Now;
                }
                else
                {
                    response.isSuccess          = false;
                    response.serverResponseTime = System.DateTime.Now;
                }
            }
            return(response);
        }
Пример #19
0
        public IEnumerable <CategoryModel> RemoveCategory(int id)
        {
            ResponseStatus       response = new ResponseStatus();
            List <CategoryModel> data     = new List <CategoryModel>();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                context.categorymasters.Remove(context.categorymasters.Where(d => d.CategoryId == id).First());
                var result = context.SaveChanges();
                if (result > 0)
                {
                    data = (from c in context.categorymasters
                            select new CategoryModel()
                    {
                        CategoryId = c.CategoryId,
                        CategoryName = c.CategoryName,
                        CategoryDescription = c.CategoryDescription,
                        StoreId = (int)c.StoreId,
                        CategoryPictures = "http://103.233.79.234/Data/EverGreen_Android/CategoryPictures/" + c.CategoryId + ".jpg",
                    }).ToList();
                }
            }
            return(data);
        }
        public ProductModel AddNewProduct(ProductModel model)
        {
            ProductModel data = new ProductModel();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                var pr = context.productmasters.Find(model.ProductId);
                if (pr != null)
                {
                    pr.CategoryId  = model.CategoryId;
                    pr.ProductName = model.ProductName;
                    pr.UnitPrice   = model.UnitPrice;
                    pr.GST         = model.GST;
                    pr.Discount    = model.Discount;
                    pr.TaxType     = model.TaxType;
                    if (model.Lock)
                    {
                        pr.Lock = "Y";
                    }
                    else
                    {
                        pr.Lock = "N";
                    }

                    pr.UOM            = model.UOM;
                    pr.ProductDetails = model.ProductDetails;
                    pr.DeliveryCharge = model.DeliveryCharge;
                    var result = context.SaveChanges();
                    if (result > 0)
                    {
                        data.ProductId = pr.ProductId;
                    }
                }
                else
                {
                    productmaster p = new productmaster();
                    p.CategoryId  = model.CategoryId;
                    p.ProductName = model.ProductName;
                    p.UnitPrice   = model.UnitPrice;
                    p.GST         = model.GST;
                    p.Discount    = model.Discount;
                    p.TaxType     = model.TaxType;
                    if (model.Lock)
                    {
                        p.Lock = "Y";
                    }
                    else
                    {
                        p.Lock = "N";
                    }

                    p.UOM            = model.UOM;
                    p.ProductDetails = model.ProductDetails;
                    p.DeliveryCharge = model.DeliveryCharge;
                    context.productmasters.Add(p);
                    var result = context.SaveChanges();
                    if (result > 0)
                    {
                        data.ProductId = p.ProductId;
                    }
                }
            }
            return(data);
        }
Пример #21
0
        public OrderModel CreateOrder(OrderModel model)
        {
            OrderModel data = new OrderModel();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                var maxseq = 0;
                var first  = context.ordermasters.Where(x => x.StoreId == model.StoreId).Select(s => s.OrderId).FirstOrDefault();
                if (first == 0)
                {
                    strSequnceNumber = "EVR00001";
                }
                else
                {
                    maxseq = context.ordermasters.Where(x => x.StoreId == model.StoreId).Max(s => s.OrderId);
                }

                if (maxseq != null && maxseq > 0)
                {
                    strSequnceNumber = MakeIntoSequence(maxseq + 1, 8, "EVR");
                }
                else
                {
                    strSequnceNumber = "EVR00001";
                }

                string  strOrderNumber    = strSequnceNumber;
                decimal grandtotal        = 0;
                decimal deliverycharge    = 0;
                decimal promocodediscount = 0;
                decimal specialdiscount   = 0;
                decimal productprice      = 0;
                decimal GSTvalue          = 0;
                decimal productvalue      = 0;
                decimal taxabale_value    = 0;
                decimal gstvalue          = 0;
                decimal productnetvalue   = 0;
                decimal Itotal            = 0;

                decimal Total               = 0;
                decimal TotalDiscount       = 0;
                decimal TotalGST            = 0;
                decimal TotalSubTotal       = 0;
                decimal TotalGrandTotal     = 0;
                decimal NetPrice            = 0;
                decimal TotalDeliveryCharge = 0;

                foreach (var pro in model.OrderDetails)
                {
                    var product = (from p in context.productmasters
                                   where p.ProductId == pro.ProductId
                                   select p).FirstOrDefault();
                    if (product.TaxType != null && product.TaxType == "I")
                    {
                        productvalue    = pro.Quantity * (decimal)product.UnitPrice;
                        specialdiscount = (productvalue * (decimal)product.Discount / 100);
                        taxabale_value  = productvalue - specialdiscount;
                        GSTvalue        = taxabale_value * (decimal)product.GST / (100 + (decimal)product.GST);
                        Itotal          = taxabale_value - GSTvalue;
                        productprice    = (decimal)pro.Quantity * Itotal + GSTvalue;
                    }
                    else
                    {
                        productvalue    = pro.Quantity * (decimal)product.UnitPrice;
                        specialdiscount = (productvalue * (decimal)product.Discount / 100);
                        taxabale_value  = productvalue - specialdiscount;
                        GSTvalue        = taxabale_value * (decimal)product.GST / 100;
                        productprice    = taxabale_value + GSTvalue;
                    }
                    TotalDeliveryCharge += (decimal)product.DeliveryCharge;
                    Total           += productvalue;
                    TotalDiscount   += specialdiscount;
                    TotalSubTotal   += taxabale_value;
                    TotalGST        += GSTvalue;
                    TotalGrandTotal += productprice;
                }
                if (model.PromoCodeId > 0)
                {
                    promocodediscount = (decimal)(from p in context.promocodemasters
                                                  where p.PromoCodeId == model.PromoCodeId && p.LoginId == model.LoginId
                                                  select p.Discount).FirstOrDefault();
                }
                else
                {
                    promocodediscount = 0;
                }

                NetPrice = TotalGrandTotal + TotalDeliveryCharge - promocodediscount;
                ordermaster o = new ordermaster();
                o.OrderNumber         = strOrderNumber;
                o.StoreId             = model.StoreId;
                o.AddressId           = model.AddressId;
                o.LoginId             = model.LoginId;
                o.TotalPrice          = Total;
                o.GrandTotal          = TotalGrandTotal;
                o.SpecialDiscount     = TotalDiscount;
                o.Discount            = promocodediscount;
                o.NetAmount           = NetPrice;
                o.TotalGST            = TotalGST;
                o.SubTotal            = TotalSubTotal;
                o.TotalDeliveryCharge = TotalDeliveryCharge;
                o.OrderStatusId       = 1;
                foreach (var product in model.OrderDetails)
                {
                    orderdetail x = new orderdetail();
                    x.OrderNumber = strOrderNumber;
                    x.ProductId   = product.ProductId;
                    x.Quantity    = product.Quantity;
                    context.orderdetails.Add(x);
                }
                context.ordermasters.Add(o);

                var result = context.SaveChanges();

                var order = (from x in context.ordermasters
                             join s in context.orderstatusmasters on x.OrderStatusId equals s.OrderStatusId
                             join p in context.promocodemasters on x.LoginId equals p.LoginId into j1
                             from j2 in j1.DefaultIfEmpty()
                             join c in context.registrationmasters on x.LoginId equals c.LoginID into j3
                             from j4 in j3.DefaultIfEmpty()
                             join st in context.storemasters on x.StoreId equals st.StoreId into j5
                             from j6 in j5.DefaultIfEmpty()
                             //join m in context.orderdetails on x.OrderNumber equals m.OrderNumber
                             where x.LoginId == model.LoginId
                             orderby x.OrderId descending
                             select new OrderModel()
                {
                    OrderId = x.OrderId,
                    CustomerName = j4.Name,
                    PhoneNumber = j4.PhoneNumber,
                    EmailId = j4.EmailID,
                    DeviceId = j4.DeviceId,
                    OrderNumber = x.OrderNumber,
                    StoreId = (int)x.StoreId,
                    StoreName = j6.StoreName,
                    StorePhoneNumber = j6.StorePhoneNumber,
                    AddressId = (int)x.AddressId,
                    LoginId = (int)x.LoginId,
                    PromoCode = j2.PromoCode,
                    TotalPrice = (decimal)x.TotalPrice,
                    GrandTotal = (decimal)x.GrandTotal,
                    SpecialDiscount = (decimal)x.SpecialDiscount,
                    PromoDiscount = (decimal)x.Discount,
                    NetPrice = (decimal)x.NetAmount,
                    SubTotal = (decimal)x.SubTotal,
                    TotalGST = (decimal)x.TotalGST,
                    OrderTime = (DateTime)x.CreatedOn,
                    OrderStatus = s.OrderStatus,
                    DeliveryCharge = (decimal)x.TotalDeliveryCharge,
                }).First();

                var orderdetails = (from z in context.ordermasters
                                    join r in context.orderdetails on z.OrderNumber equals r.OrderNumber
                                    join p in context.productmasters on r.ProductId equals p.ProductId
                                    where r.OrderNumber == order.OrderNumber
                                    orderby r.OrderDetailsId descending
                                    select new OrderDetailsModel()
                {
                    ProductName = p.ProductName,
                    UnitPrice = (decimal)p.UnitPrice,
                    ProductId = (int)r.ProductId,
                    Quantity = (decimal)r.Quantity,
                    UOM = p.UOM,
                    //ProductPicturesUrl = path + r.ProductId + "ProductPictures.jpg"
                }).ToList();
                order.OrderDetails = orderdetails;
                return(order);
            }
        }
Пример #22
0
        public UserModel SocialUserLogin(UserModel model)
        {
            UserModel          user = new UserModel();
            registrationmaster us   = new registrationmaster();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                var data = context.registrationmasters.Where(x => x.PhoneNumber == model.PhoneNumber).FirstOrDefault();
                if (data != null)
                {
                    us = context.registrationmasters.Find(data.LoginID);
                    if (us != null)
                    {
                        us.Name        = model.Name;
                        us.PhoneNumber = model.PhoneNumber;
                        us.OTP         = Convert.ToString(SendOTP(model.PhoneNumber));
                        us.Role        = Convert.ToInt32(model.Role);
                        us.FbToken     = model.FbToken;
                        us.EmailID     = model.EmailID;
                        us.DeviceId    = model.DeviceId;
                        try
                        {
                            //user.ProfilePictureUrl = "http://103.233.79.234/Data/EverGreen_Android/EverGreenProfilePicture/" + us.LoginID + ".jpeg";
                            string path   = "C:/inetpub/wwwroot/Data/EverGreen_Android/EverGreenProfilePicture/" + model.LoginID + ".jpeg";
                            var    bytess = Convert.FromBase64String(user.ProfilePictureUrl);
                            using (var imageFile = new FileStream(path, FileMode.Create))
                            {
                                imageFile.Write(bytess, 0, bytess.Length);
                                imageFile.Flush();
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                        var r = context.SaveChanges();
                        if (r > 0)
                        {
                            user.LoginID           = Convert.ToInt32(us.LoginID);
                            user.Name              = us.Name;
                            user.PhoneNumber       = us.PhoneNumber;
                            user.Otp               = Convert.ToInt32(us.OTP);
                            user.Role              = Convert.ToInt32(us.Role);
                            user.FbToken           = us.FbToken;
                            user.EmailID           = us.EmailID;
                            user.DeviceId          = us.DeviceId;
                            user.ProfilePictureUrl = "http://103.233.79.234/Data/EverGreen_Android/EverGreenProfilePicture/" + us.LoginID + ".jpeg";
                        }
                        return(user);
                    }
                }
                else
                {
                    registrationmaster u = new registrationmaster();
                    u.Name        = model.Name;
                    u.PhoneNumber = model.PhoneNumber;
                    u.EmailID     = model.EmailID;
                    u.FbToken     = model.FbToken;
                    u.OTP         = Convert.ToString(SendOTP(model.PhoneNumber));
                    u.DeviceId    = model.DeviceId;
                    context.registrationmasters.Add(u);
                    var result = context.SaveChanges();
                    if (result > 0)
                    {
                        var userdata = context.registrationmasters.Where(x => x.PhoneNumber == model.PhoneNumber).FirstOrDefault();
                        if (userdata != null)
                        {
                            try
                            {
                                string path   = "C:/inetpub/wwwroot/Data/EverGreen_Android/EverGreenProfilePicture/" + u.LoginID + ".jpeg";
                                var    bytess = GetBytes(model.ProfilePictureUrl);

                                using (var imageFile = new FileStream(path, FileMode.Create))
                                {
                                    imageFile.Write(bytess, 0, bytess.Length);
                                    imageFile.Flush();
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                            user.LoginID           = Convert.ToInt32(userdata.LoginID);
                            user.Name              = userdata.Name;
                            user.PhoneNumber       = userdata.PhoneNumber;
                            user.Otp               = Convert.ToInt32(userdata.OTP);
                            user.Role              = Convert.ToInt32(userdata.Role);
                            user.FbToken           = userdata.FbToken;
                            user.EmailID           = userdata.EmailID;
                            user.DeviceId          = us.DeviceId;
                            user.ProfilePictureUrl = "http://103.233.79.234/Data/EverGreen_Android/EverGreenProfilePicture/" + userdata.LoginID + ".jpeg";
                        }
                    }
                }
            }
            return(user);
        }
Пример #23
0
        public StoreModel AddUpdateFavouriteStoreByUser(int loginid, int storeid)
        {
            StoreModel store = new StoreModel();

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                if (loginid > 0 && storeid > 0)
                {
                    var data = context.registrationmasters.Where(w => w.LoginID.Equals(loginid));
                    foreach (var item in data)
                    {
                        item.FavouriteStoreId = storeid;
                    }
                    try
                    {
                        var resultdata = context.SaveChanges();
                        if (resultdata > 0)
                        {
                            var favouriteStore = (from s in context.storemasters
                                                  join u in context.registrationmasters on s.StoreId equals u.FavouriteStoreId into jointable
                                                  from z in jointable.DefaultIfEmpty()
                                                  //join l in context.localitymasters on s.StoreId equals l.StoreId1 into j1
                                                  //from j2 in j1.DefaultIfEmpty()
                                                  //join l in context.localitymasters on s.StoreId equals l.StoreId2 into j3
                                                  //from j4 in j1.DefaultIfEmpty()
                                                  //join l in context.localitymasters on s.StoreId equals l.StoreId1 into j5
                                                  //from j6 in j1.DefaultIfEmpty()
                                                  where z.LoginID == loginid && s.StoreStatus == "Y"
                                                  orderby s.StoreName
                                                  select z.FavouriteStoreId).SingleOrDefault();
                            var result = (from u in context.registrationmasters
                                          join s in context.storemasters on u.FavouriteStoreId equals s.StoreId
                                          where u.LoginID == (long)loginid && u.FavouriteStoreId == storeid
                                          select new StoreModel()
                            {
                                StoreId = s.StoreId,
                                StoreName = s.StoreName,
                                StoreStatus = s.StoreStatus == "Y" ? true : false,
                                OpeningTime = (DateTime)s.OpeningTime,
                                ClosingTime = (DateTime)s.ClosingTime,
                                StoreEmailId = s.StoreEmailId,
                                StorePhoneNumber = s.StorePhoneNumber,
                                StoreAddress = s.StoreAddress,
                                StorePicturesUrl = "http://103.233.79.234/Data/EverGreen_Android/StorePictures/" + s.StoreId + ".jpg",
                                FavouriteStore = s.StoreId == favouriteStore ? true : false,
                            }).FirstOrDefault();
                            store = result;
                        }
                        else
                        {
                            var favouriteStore = (from s in context.storemasters
                                                  join u in context.registrationmasters on s.StoreId equals u.FavouriteStoreId into jointable
                                                  from z in jointable.DefaultIfEmpty()
                                                  //join l in context.localitymasters on s.StoreId equals l.StoreId1 into j1
                                                  //from j2 in j1.DefaultIfEmpty()
                                                  //join l in context.localitymasters on s.StoreId equals l.StoreId2 into j3
                                                  //from j4 in j1.DefaultIfEmpty()
                                                  //join l in context.localitymasters on s.StoreId equals l.StoreId1 into j5
                                                  //from j6 in j1.DefaultIfEmpty()
                                                  where z.LoginID == loginid && s.StoreStatus == "Y"
                                                  orderby s.StoreName
                                                  select z.FavouriteStoreId).SingleOrDefault();
                            var result = (from u in context.registrationmasters
                                          join s in context.storemasters on u.FavouriteStoreId equals s.StoreId
                                          where u.LoginID == (long)loginid && u.FavouriteStoreId == storeid
                                          select new StoreModel()
                            {
                                StoreId = s.StoreId,
                                StoreName = s.StoreName,
                                StoreStatus = s.StoreStatus == "Y" ? true : false,
                                OpeningTime = (DateTime)s.OpeningTime,
                                ClosingTime = (DateTime)s.ClosingTime,
                                StoreEmailId = s.StoreEmailId,
                                StorePhoneNumber = s.StorePhoneNumber,
                                StoreAddress = s.StoreAddress,
                                StorePicturesUrl = "http://103.233.79.234/Data/EverGreen_Android/StorePictures/" + s.StoreId + ".jpg",
                                FavouriteStore = s.StoreId == favouriteStore ? true : false,
                            }).FirstOrDefault();
                            store = result;
                        }
                    }
                    catch (Exception ex)
                    {
                        //Handle ex
                    }
                }
            }
            return(store);
        }
        public PaymentResponseModel CreatePaymentOrder(int loginid, string ordernumber, int storeid)
        {
            PaymentResponseModel response = new PaymentResponseModel();
            string transaction_id         = "";
            string OrderNumber            = "";

            using (evergreen_androidEntities context = new evergreen_androidEntities())
            {
                var orderDetails = (from r in context.registrationmasters
                                    join o in context.ordermasters on r.LoginID equals o.LoginId
                                    where r.LoginID == loginid && o.OrderNumber == ordernumber && o.StoreId == storeid
                                    select new PaymentGatewayModel()
                {
                    name = r.Name,
                    phone = r.PhoneNumber,
                    email = r.EmailID,
                    description = o.OrderNumber,
                    amount = (double)o.NetAmount
                }).First();
                //For Production
                //string Insta_client_id = "YPmEwDVMbYy4hH9EZOcY4Vsw3xJWjnAd3qlTS85J",
                //       Insta_client_secret = "fSiNKEG8PRLdOXSzpQrBba02Ix1sfbxDSHg3f562AFY0YqvgKXMm70wbE6vqxzmmpVOKB1MyG3tlwDzX4rzNXwRwqaHVafFQv1gkj4kNf14x1eeync9PoMuGtOulBxJk",
                //       Insta_Endpoint = InstamojoConstants.INSTAMOJO_API_ENDPOINT,
                //       Insta_Auth_Endpoint = InstamojoConstants.INSTAMOJO_AUTH_ENDPOINT;

                //For Test

                string Insta_client_id     = "";
                string Insta_client_secret = "";
                string Insta_Endpoint      = "";
                string Insta_Auth_Endpoint = "";
                if (storeid == 1)
                {
                    Insta_client_id     = "HhWceDXORiCKCKIechUmXZX6vd4nj44kKvCUIVJv";
                    Insta_client_secret = "5B6CAfNsEoaakuzWLia7CMtgFsp6gt0MTrN5jR0MzsTIerNXKjmS9k1bBS1J8LdANjKXWtmlR1RuiOM8o71JVYYawBCl4NRiWbpKrI8OwkwnjNlvOuYRnjfkGnjozZDM";
                    Insta_Endpoint      = InstamojoConstants.INSTAMOJO_API_ENDPOINT;
                    Insta_Auth_Endpoint = InstamojoConstants.INSTAMOJO_AUTH_ENDPOINT;
                }
                if (storeid == 2)
                {
                    Insta_client_id     = "tmLkZZ0zV41nJwhayBGBOI4m4I7bH55qpUBdEXGS";
                    Insta_client_secret = "IDejdccGqKaFlGav9bntKULvMZ0g7twVFolC9gdrh9peMS0megSFr7iDpWwWIDgFUc3W5SlX99fKnhxsoy6ipdAv9JeQwebmOU6VRvOEQnNMWwZnWglYmDGrfgKRheXs";
                    Insta_Endpoint      = InstamojoConstants.INSTAMOJO_API_ENDPOINT;
                    Insta_Auth_Endpoint = InstamojoConstants.INSTAMOJO_AUTH_ENDPOINT;
                }
                if (storeid == 3)
                {
                    Insta_client_id     = "tmLkZZ0zV41nJwhayBGBOI4m4I7bH55qpUBdEXGS";
                    Insta_client_secret = "IDejdccGqKaFlGav9bntKULvMZ0g7twVFolC9gdrh9peMS0megSFr7iDpWwWIDgFUc3W5SlX99fKnhxsoy6ipdAv9JeQwebmOU6VRvOEQnNMWwZnWglYmDGrfgKRheXs";
                    Insta_Endpoint      = InstamojoConstants.INSTAMOJO_API_ENDPOINT;
                    Insta_Auth_Endpoint = InstamojoConstants.INSTAMOJO_AUTH_ENDPOINT;
                }

                InstamojoAPI.Instamojo objClass = InstamojoImplementation.getApi(Insta_client_id, Insta_client_secret, Insta_Endpoint, Insta_Auth_Endpoint);


                PaymentOrder objPaymentRequest = new PaymentOrder();
                //Required POST parameters
                objPaymentRequest.name        = orderDetails.name;
                objPaymentRequest.email       = orderDetails.email;
                objPaymentRequest.phone       = orderDetails.phone;
                objPaymentRequest.description = orderDetails.description;
                objPaymentRequest.amount      = orderDetails.amount;
                objPaymentRequest.currency    = "INR";

                string randomName = Path.GetRandomFileName();
                randomName = randomName.Replace(".", string.Empty);
                objPaymentRequest.transaction_id = "EVG" + randomName;

                transaction_id = objPaymentRequest.transaction_id;
                OrderNumber    = objPaymentRequest.description;

                //For Production
                //objPaymentRequest.redirect_url = "http://103.233.79.234:1000/";
                //objPaymentRequest.webhook_url = "https://your.server.com/webhook";
                //Extra POST parameters

                //For Test
                objPaymentRequest.redirect_url = "https://swaggerhub.com/api/saich/pay-with-instamojo/1.0.0";
                objPaymentRequest.webhook_url  = "https://your.server.com/webhook";

                if (objPaymentRequest.validate())
                {
                    //if (objPaymentRequest.emailInvalid)
                    //{
                    //    response.Message = "Email is not valid";
                    //}
                    //if (objPaymentRequest.nameInvalid)
                    //{
                    //    response.Message = "Name is not valid";
                    //}
                    if (objPaymentRequest.phoneInvalid)
                    {
                        response.Message = "Phone is not valid";
                    }
                    if (objPaymentRequest.amountInvalid)
                    {
                        response.Message = "Amount is not valid";
                    }
                    if (objPaymentRequest.currencyInvalid)
                    {
                        response.Message = "Currency is not valid";
                    }
                    if (objPaymentRequest.transactionIdInvalid)
                    {
                        response.Message = "Transaction Id is not valid";
                    }
                    if (objPaymentRequest.redirectUrlInvalid)
                    {
                        response.Message = "Redirect Url Id is not valid";
                    }
                    if (objPaymentRequest.webhookUrlInvalid)
                    {
                        response.Message = "Webhook URL is not valid";
                    }
                }
                else
                {
                    try
                    {
                        CreatePaymentOrderResponse objPaymentResponse = objClass.createNewPaymentRequest(objPaymentRequest);
                        response.PaymentURL = objPaymentResponse.payment_options.payment_url;
                        var data = context.ordermasters.Where(x => x.LoginId == loginid && x.OrderNumber == ordernumber && x.StoreId == storeid).FirstOrDefault();
                        if (data != null)
                        {
                            context.ordermasters.Where(x => x.LoginId == loginid && x.OrderNumber == ordernumber && x.StoreId == storeid).ToList().ForEach(x => x.TranactionId = transaction_id);
                            context.SaveChanges();
                        }
                    }
                    catch (ArgumentNullException ex)
                    {
                        response.Message = ex.Message;
                    }
                    catch (WebException ex)
                    {
                        response.Message = ex.Message;
                    }
                    catch (IOException ex)
                    {
                        response.Message = ex.Message;
                    }
                    catch (InvalidPaymentOrderException ex)
                    {
                        if (!ex.IsWebhookValid())
                        {
                            response.Message = "Webhook is invalid";
                        }

                        if (!ex.IsCurrencyValid())
                        {
                            response.Message = "Currency is Invalid";
                        }

                        if (!ex.IsTransactionIDValid())
                        {
                            response.Message = "Transaction ID is Invalid";
                        }
                    }
                    catch (ConnectionException ex)
                    {
                        response.Message = ex.Message;
                    }
                    catch (BaseException ex)
                    {
                        response.Message = ex.Message;
                    }
                    catch (Exception ex)
                    {
                        response.Message = ex.Message;
                    }
                }
            }
            return(response);
        }