public UserModel UploadProfilePicture(int loginid) { UserModel users = new UserModel(); using (evergreen_androidEntities context = new evergreen_androidEntities()) { registrationmaster u = new registrationmaster(); var data = context.registrationmasters.Where(x => x.LoginID == loginid).FirstOrDefault(); if (data != null) { 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/"+ loginid + ".jpg"; //users.ProfilePictureUrl = "http:/localhost:51673/Data/EverGreen_Android/EverGreenProfilePicture/" + loginid + ".jpg"; } } return users; }
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); }
//string path = "http://103.233.79.234/Data/EverGreen_Android/StorePictures/"; //public IEnumerable<StoreModel> GetAllStoreByLocality(int localityid, int loginId) //{ // List<StoreModel> stores = new List<StoreModel>(); // StoreModel store = new StoreModel(); // using (evergreen_androidEntities context = new evergreen_androidEntities()) // { // bool fav; // 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 s.LocalityId == localityid && z.LoginID == loginId // orderby s.StoreName // select z.FavouriteStoreId).SingleOrDefault(); // stores = (from s in context.storemasters // where s.LocalityId == localityid // select new StoreModel() // { // StoreId = s.StoreId, // StoreName = s.StoreName, // StoreEmailId = s.StoreEmailId, // StorePhoneNumber = s.StorePhoneNumber, // StoreAddress = s.StoreAddress, // StorePicturesUrl = path + s.StoreId + "StorePictures.jpg", // FavouriteStore = s.StoreId == favouriteStore ? true : false, // }).ToList(); // } // return stores; //} public IEnumerable <StoreModel> GetAllStoreByLocality(int localityid, int loginId) { List <StoreModel> stores = new List <StoreModel>(); StoreModel store = new StoreModel(); using (evergreen_androidEntities context = new evergreen_androidEntities()) { bool fav; 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 = context.localitymasters.Where(s => s.LocalityId == localityid).FirstOrDefault(); if (result.StoreId1 > 0) { store = (from s in context.storemasters where s.StoreId == result.StoreId1 select new StoreModel() { StoreId = s.StoreId, StoreName = s.StoreName, StoreEmailId = s.StoreEmailId, StorePhoneNumber = s.StorePhoneNumber, StoreAddress = s.StoreAddress, LocalityId = result.LocalityId, 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", //StorePicturesUrl = path + s.StoreId + "StorePictures.jpg", FavouriteStore = s.StoreId == favouriteStore ? true : false, }).FirstOrDefault(); stores.Add(store); } if (result.StoreId2 > 0) { store = (from s in context.storemasters where s.StoreId == result.StoreId2 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, LocalityId = result.LocalityId, StorePicturesUrl = "http://103.233.79.234/Data/EverGreen_Android/StorePictures/" + s.StoreId + ".jpg", FavouriteStore = s.StoreId == favouriteStore ? true : false, }).FirstOrDefault(); stores.Add(store); } if (result.StoreId3 > 0) { store = (from s in context.storemasters where s.StoreId == result.StoreId3 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, LocalityId = result.LocalityId, StorePicturesUrl = "http://103.233.79.234/Data/EverGreen_Android/StorePictures/" + s.StoreId + ".jpg", FavouriteStore = s.StoreId == favouriteStore ? true : false, }).FirstOrDefault(); stores.Add(store); } } return(stores); }
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); }
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); }
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); } }
public OrderModel SendSmsAndEmail(string ordernumber) { OrderModel data = new OrderModel(); using (evergreen_androidEntities context = new evergreen_androidEntities()) { 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.OrderNumber == ordernumber 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, }).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; data = order; if (data.OrderNumber != null) { SendSMS(data); SendEmail(data); SendNotification(data); } } return(data); }
public IEnumerable <ProductModel> GetAllProductList(int StoreId) { List <ProductModel> data = new List <ProductModel>(); using (evergreen_androidEntities context = new evergreen_androidEntities()) { if (StoreId == 0) { data = (from p in context.productmasters join c in context.categorymasters on p.CategoryId equals c.CategoryId into j1 from j2 in j1.DefaultIfEmpty() where p.Lock == "N" 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", ProductPicturesUrl = "http://localhost/Data/EverGreen_Android/ProductPictures/" + p.ProductId + ".jpg?" + DateTime.Now.ToString(), }).ToList(); } else { data = (from p in context.productmasters join c in context.categorymasters on p.CategoryId equals c.CategoryId into j1 from j2 in j1.DefaultIfEmpty() where j2.StoreId == StoreId && p.Lock == "N" 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://localhost/Data/EverGreen_Android/ProductPictures/" + p.ProductId + ".jpg?" + DateTime.Now.ToString(), }).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); }