Exemple #1
0
 public void updateprofile(profileupdate prof)
 {
     try
     {
         bool tknVld = GF.ValidateToken(prof.DEVICE_ID, prof.TOKEN);
         if (tknVld == true)
         {
             PA_MOB_CUST_SIGHN_UP cfs = db.PA_MOB_CUST_SIGHN_UP.AsEnumerable().Where(x => x.EMAIL_ID.ToUpper().Trim() == prof.USER_ID.ToUpper().Trim() && x.ISACTIVE == true).SingleOrDefault();
             if (cfs != null)
             {
                 cfs.MOBILE_NO = prof.MOBILE_NO;
                 cfs.ADDRESS   = prof.ADDRESS;
                 db.SaveChanges();
                 db.Entry(cfs).State = EntityState.Detached;
                 var routData = new CMNObject
                 {
                     STATUS_CODE = 200,
                     MESSAGE     = "Profile Successfully Updated"
                 };
                 json = JsonConvert.SerializeObject(routData, Formatting.Indented);
             }
             else
             {
                 var routedata = new CMNObject
                 {
                     STATUS_CODE = 401,
                     MESSAGE     = "Invalid USER ID"
                 };
                 json = JsonConvert.SerializeObject(routedata, Formatting.Indented);
             }
         }
         else
         {
             var routedata = new CMNObject
             {
                 STATUS_CODE = 401,
                 MESSAGE     = "Invalid User"
             };
             json = JsonConvert.SerializeObject(routedata, Formatting.Indented);
         }
     }
     catch (Exception ex)
     {
         var routData = new CMNObject
         {
             STATUS_CODE = 401,
             MESSAGE     = ex.Message
         };
         json = JsonConvert.SerializeObject(routData, Formatting.Indented);
     }
     HttpContext.Current.Response.Clear();
     HttpContext.Current.Response.Buffer          = true;
     HttpContext.Current.Response.Charset         = "UTF-8";
     HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
     HttpContext.Current.Response.ContentType     = "application/json";
     HttpContext.Current.Response.Write(json);
     HttpContext.Current.Response.End();
 }
Exemple #2
0
        public void Addtocart(Addtotemp addobj)
        {
            try
            {
                bool tknVld = GF.ValidateToken(addobj.DEVICEID, addobj.TOKEN);
                if (tknVld == true)
                {
                    var ordDetails = addobj.ITEMDETAILS;
                    foreach (var item in ordDetails)
                    {
                        TEMP_PA_CART_DATA tp = new TEMP_PA_CART_DATA();
                        tp.CUSTOMER_ID = addobj.USER_ID;
                        tp.ITEM_ID     = item.ITEM_ID;
                        tp.QUANTITY    = item.ITEM_QUANTITY;
                        tp.CREATED_ON  = DateTime.Now;
                        tp.ISACTIVE    = true;
                        db.TEMP_PA_CART_DATA.Add(tp);
                        db.SaveChanges();
                    }

                    var routedata = new CMNObject
                    {
                        STATUS_CODE = 200,
                        MESSAGE     = "Product Saved on Db"
                    };
                    json = JsonConvert.SerializeObject(routedata, Formatting.Indented);
                }
                else
                {
                    var routedata = new CMNObject
                    {
                        STATUS_CODE = 401,
                        MESSAGE     = "Invalid User"
                    };
                    json = JsonConvert.SerializeObject(routedata, Formatting.Indented);
                }
            }
            catch (Exception ex)
            {
                var routData = new CMNObject
                {
                    STATUS_CODE = 401,
                    MESSAGE     = ex.Message
                };
                json = JsonConvert.SerializeObject(routData, Formatting.Indented);
            }
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Buffer          = true;
            HttpContext.Current.Response.Charset         = "UTF-8";
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
            HttpContext.Current.Response.ContentType     = "application/json";
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }
Exemple #3
0
        public void Categories()
        {
            try
            {
                var             categories   = db.PA_MASTER_GENERAL.AsEnumerable().Where(a => a.CODEACCESS == true && a.CODEYPE == "Item_Category").ToList();
                List <Category> CATEGORYList = new List <Category>();

                var url = GetFileUrl(VirtualPathUtility.ToAbsolute("~/Content/Category/"), false);
                foreach (var mod in categories)
                {
                    CATEGORYList.Add(new Category()
                    {
                        CATEGORY_ID    = mod.CODEID,
                        CATEGORY_NAME  = mod.CODEDESC,
                        CATEGORY_PHOTO = url + "" + mod.CODEID + "" + ".jpg"
                    });
                }
                var routData = new CATE_LIST
                {
                    STATUS_CODE   = 200,
                    MESSAGE       = "Success",
                    CATEGORY_LIST = CATEGORYList
                };
                json = JsonConvert.SerializeObject(routData, Formatting.Indented);
            }
            catch (Exception ex)
            {
                var routData = new CMNObject
                {
                    STATUS_CODE = 401,
                    MESSAGE     = ex.Message
                };
                json = JsonConvert.SerializeObject(routData, Formatting.Indented);
            }
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Buffer          = true;
            HttpContext.Current.Response.Charset         = "UTF-8";
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
            HttpContext.Current.Response.ContentType     = "application/json";
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }
Exemple #4
0
 public void AvailableItem(AvlItem avlitem)
 {
     try
     {
         var isavlitem = db.PA_MASTER_ITEM.AsEnumerable().Where(x => x.ITEM_ID == avlitem.ITEM_ID).FirstOrDefault();
         if (isavlitem.ITEM_QUANTITY >= avlitem.QUANTITY)
         {
             var routData = new CMNObject
             {
                 STATUS_CODE = 200,
                 MESSAGE     = "Item Available"
             };
             json = JsonConvert.SerializeObject(routData, Formatting.Indented);
         }
         else
         {
             var routData = new CMNObject
             {
                 STATUS_CODE = 201,
                 MESSAGE     = "Out of Stock"
             };
             json = JsonConvert.SerializeObject(routData, Formatting.Indented);
         }
     }
     catch (Exception ex)
     {
         var routData = new CMNObject
         {
             STATUS_CODE = 401,
             MESSAGE     = ex.Message
         };
         json = JsonConvert.SerializeObject(routData, Formatting.Indented);
     }
     HttpContext.Current.Response.Clear();
     HttpContext.Current.Response.Buffer          = true;
     HttpContext.Current.Response.Charset         = "UTF-8";
     HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
     HttpContext.Current.Response.ContentType     = "application/json";
     HttpContext.Current.Response.Write(json);
     HttpContext.Current.Response.End();
 }
Exemple #5
0
        public void UserSignUp(P_GHAR_API.Classes.SignUp data)
        {
            try
            {
                if (db.PA_MOB_CUST_SIGHN_UP.AsEnumerable().Where(x => x.EMAIL_ID.ToUpper().Trim() == data.EMAIL_ID.ToUpper().Trim()).Count() > 0)
                {
                    var routData = new CMNObject
                    {
                        STATUS_CODE = 201,
                        MESSAGE     = "Credential already exists."
                    };
                    json = JsonConvert.SerializeObject(routData, Formatting.Indented);
                }
                else
                {
                    PA_MOB_CUST_SIGHN_UP SU = new PA_MOB_CUST_SIGHN_UP();
                    SU.FIRST_NAME = data.FIRST_NAME;
                    SU.LAST_NAME  = data.LAST_NAME;
                    SU.EMAIL_ID   = data.EMAIL_ID;
                    SU.MOBILE_NO  = data.MOBILE_NO;
                    SU.ISACTIVE   = false;
                    SU.PASSWORD   = EncryptDecrypt.Encrypt(data.PASSWORD);
                    SU.C_ON       = DateTime.Now.ToString("dd/MM/yyyy");
                    db.PA_MOB_CUST_SIGHN_UP.Add(SU);
                    db.SaveChanges();

                    string CUSTNAME      = data.FIRST_NAME + " " + data.LAST_NAME;
                    var    senderEmail   = new MailAddress("*****@*****.**", "Welcome " + CUSTNAME);
                    var    receiverEmail = new MailAddress(data.EMAIL_ID, "Receiver");
                    // var password = "******";
                    string subject = "VeggieRhino";
                    string htmlBody;
                    htmlBody = GF.PopulateBody(db.PA_MOB_CUST_SIGHN_UP.AsEnumerable().Where(x => x.EMAIL_ID == data.EMAIL_ID).Select(x => x.CUST_ID).FirstOrDefault(), CUSTNAME);

                    MailMessage mail = new MailMessage();
                    mail.To.Add(data.EMAIL_ID);
                    mail.From       = new MailAddress("*****@*****.**", "VeggieRhino Customer Verification");
                    mail.Subject    = subject;
                    mail.IsBodyHtml = true;
                    string sbody = htmlBody;

                    mail.Body = sbody;
                    SmtpClient smtp = new SmtpClient();
                    smtp.Host        = "smtp.gmail.com";
                    smtp.Port        = 25;
                    smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "VeggieRhino@2020");
                    smtp.EnableSsl   = true;
                    if (data.EMAIL_ID != "")
                    {
                        smtp.Send(mail);
                    }

                    var routData = new CMNObject
                    {
                        STATUS_CODE = 200,
                        MESSAGE     = "Succesfully Sign Up,Link Shared on your email id please Verify Your Account."
                    };
                    json = JsonConvert.SerializeObject(routData, Formatting.Indented);
                    // bool ismailsent =   GF.SendEmail(data.EMAIL_ID, db.PA_MOB_CUST_SIGHN_UP.AsEnumerable().Where(x => x.EMAIL_ID == data.EMAIL_ID).Select(x => x.CUST_ID).FirstOrDefault(), data.FIRST_NAME);
                    // if(ismailsent==true)
                    // {
                    //     var routData = new CMNObject
                    //     {
                    //         STATUS_CODE = 200,
                    //         MESSAGE = "Succesfully Sign Up,Link Shared on your email id please Verify Your Account"
                    //     };
                    //     json = JsonConvert.SerializeObject(routData, Formatting.Indented);
                    // }
                    //else
                    // {
                    //     var routData = new CMNObject
                    //     {
                    //         STATUS_CODE = 200,
                    //         MESSAGE = "Succesfully Sign Up,Some problem Occured during sending verification mail on your email id."
                    //     };
                    //     json = JsonConvert.SerializeObject(routData, Formatting.Indented);
                    // }
                }
            }
            catch (Exception ex)
            {
                var routData = new CMNObject
                {
                    STATUS_CODE = 401,
                    MESSAGE     = ex.Message
                };
                json = JsonConvert.SerializeObject(routData, Formatting.Indented);
            }
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Buffer          = true;
            HttpContext.Current.Response.Charset         = "UTF-8";
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
            HttpContext.Current.Response.ContentType     = "application/json";
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }
Exemple #6
0
 public void UserAuthentication(MobileAppToken userToken)
 {
     try
     {
         if (true)
         {
             string TOKEN = GenerateToken();
             #region login
             if (objTokenGeneration.UpdateToken(userToken, TOKEN) == true)
             {
                 var data = db.PA_MOB_CUST_SIGHN_UP.AsEnumerable().Where(x => x.EMAIL_ID.ToUpper().Trim() == userToken.USER_ID.ToUpper().Trim() && x.PASSWORD == EncryptDecrypt.Encrypt(userToken.PASSWORD) && x.ISACTIVE == true).ToList();
                 try
                 {
                     var routData = new SuccessDataObject
                     {
                         STATUS_CODE = 200,
                         MESSAGE     = "Succesfully Login",
                         TOKEN       = TOKEN,
                         USER_ID     = userToken.USER_ID,
                         USER_NAME   = data.AsEnumerable().Select(x => x.FIRST_NAME).FirstOrDefault() + " " + data.AsEnumerable().Select(x => x.LAST_NAME).FirstOrDefault(),
                         MOBILE_NO   = data.AsEnumerable().Select(x => x.MOBILE_NO).FirstOrDefault()
                     };
                     json = JsonConvert.SerializeObject(routData, Formatting.Indented);
                 }
                 catch (Exception ex)
                 {
                     var routData = new CMNObject
                     {
                         STATUS_CODE = 500,
                         MESSAGE     = "Login Fail",
                     };
                     json = JsonConvert.SerializeObject(routData, Formatting.Indented);
                 }
             }
             #endregion
             else
             {
                 var routData = new CMNObject
                 {
                     STATUS_CODE = 404,
                     MESSAGE     = "User Not Authenticated"
                 };
                 json = JsonConvert.SerializeObject(routData, Formatting.Indented);
             }
         }
         else
         {
             var routData = new CMNObject
             {
                 STATUS_CODE = 201,
                 MESSAGE     = "Wrong User Cridentials !!"
             };
             json = JsonConvert.SerializeObject(routData, Formatting.Indented);
         }
     }
     catch (Exception ex)
     {
         var routData = new CMNObject
         {
             STATUS_CODE = 401,
             MESSAGE     = ex.Message
         };
         json = JsonConvert.SerializeObject(routData, Formatting.Indented);
     }
     HttpContext.Current.Response.Clear();
     HttpContext.Current.Response.Buffer          = true;
     HttpContext.Current.Response.Charset         = "UTF-8";
     HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
     HttpContext.Current.Response.ContentType     = "application/json";
     HttpContext.Current.Response.Write(json);
     HttpContext.Current.Response.End();
 }
Exemple #7
0
 public void ItmbasedonCatg(items itm)
 {
     try
     {
         if (db.PA_MASTER_GENERAL.AsEnumerable().Where(x => x.CODEACCESS == true && x.CODEYPE == "Item_Category" && x.CODEID == itm.CATEGORY_ID).FirstOrDefault() != null)
         {
             var Products = db.PA_MASTER_ITEM.AsEnumerable().Where(x => x.ITEM_CATEGORY == itm.CATEGORY_ID && x.ISACTIVE == true)
                            .Join(db.PA_MASTER_GENERAL.AsEnumerable().Where(a => a.CODEACCESS == true && a.CODEYPE == "Item_Category"), a => a.ITEM_CATEGORY, b => b.CODEID, (a, b) => new { a, b })
                            .Join(db.PA_MASTER_GENERAL.AsEnumerable().Where(a => a.CODEACCESS == true && a.CODEYPE == "Item_Unit"), c => c.a.ITEM_CATEGORY, d => d.CODEID, (c, d) => new { c, d }).ToList();
             List <ItemsList> lstdata = new List <ItemsList>();
             if (Products.Count > 0)
             {
                 foreach (var mod in Products)
                 {
                     lstdata.Add(new ItemsList()
                     {
                         CATEGORY_NAME    = mod.c.b.CODEDESC,
                         ITEM_ID          = Convert.ToString(mod.c.a.ITEM_ID),
                         ITEM_NAME        = mod.c.a.ITEM_NAME,
                         ITEM_DESCRIPTION = mod.c.a.ITEM_DESCRIPTION,
                         ITEM_PRICE       = mod.c.a.ITEM_PRICE,
                         ITEM_PHOTO       = mod.c.a.ITEM_PHOTO,
                         ITEM_UNIT        = mod.d.CODEDESC,
                         ITEM_QUANTITY    = mod.c.a.ITEM_QUANTITY,
                         C_ON             = mod.c.a.ENTRYON.Value.Date.ToString("dd/MM/yyyy")
                     });
                 }
                 var routData = new CATE_ITEM_LIST
                 {
                     STATUS_CODE = 200,
                     MESSAGE     = "Success",
                     ITEMS       = lstdata
                 };
                 json = JsonConvert.SerializeObject(routData, Formatting.Indented);
             }
             else
             {
                 var routData = new CMNObject
                 {
                     STATUS_CODE = 401,
                     MESSAGE     = "Products Not Available"
                 };
                 json = JsonConvert.SerializeObject(routData, Formatting.Indented);
             }
         }
         else
         {
             var routData = new CMNObject
             {
                 STATUS_CODE = 401,
                 MESSAGE     = "Category Not Available"
             };
             json = JsonConvert.SerializeObject(routData, Formatting.Indented);
         }
     }
     catch (Exception ex)
     {
         var routData = new CMNObject
         {
             STATUS_CODE = 401,
             MESSAGE     = ex.Message
         };
         json = JsonConvert.SerializeObject(routData, Formatting.Indented);
     }
     HttpContext.Current.Response.Clear();
     HttpContext.Current.Response.Buffer          = true;
     HttpContext.Current.Response.Charset         = "UTF-8";
     HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
     HttpContext.Current.Response.ContentType     = "application/json";
     HttpContext.Current.Response.Write(json);
     HttpContext.Current.Response.End();
 }
Exemple #8
0
        public void CategoryWiseItems(items itm)
        {
            try
            {
                var categories = db.PA_MASTER_ITEM.AsEnumerable().Select(c => c.ITEM_CATEGORY);
                List <CategoryWiseItems> subCategories = new List <CategoryWiseItems>();
                var data = (from f in db.PA_MASTER_ITEM.AsEnumerable().ToList()
                            join d in db.PA_MASTER_GENERAL.AsEnumerable().Where(a => a.CODEACCESS == true && a.CODEYPE == "Item_Category").ToList() on f.ITEM_CATEGORY equals d.CODEID
                            select new mydata {
                    CODEID = d.CODEID,
                    Name = f.ITEM_NAME,
                    ITEM_ID = Convert.ToString(f.ITEM_ID),
                    ITEM_NAME = f.ITEM_NAME,
                    CATEGORY_ID = Convert.ToInt32(f.ITEM_CATEGORY),
                    CATEGORY_NAME = d.CODEDESC,
                    ITEM_DESCRIPTION = f.ITEM_DESCRIPTION,
                    ITEM_PRICE = f.ITEM_PRICE,
                    ITEM_PHOTO = f.ITEM_PHOTO,
                    ITEM_UNIT = f.ITEM_UNIT,
                    ITEM_QUANTITY = f.ITEM_QUANTITY,
                    // C_ON =f.ENTRYON.ToString("dd/MM/yyyy")
                }).ToList();

                foreach (var item in db.PA_MASTER_GENERAL.Where(a => a.CODEACCESS == true && a.CODEYPE == "Item_Category").ToList())
                {
                    var data1 = data.Where(x => x.CODEID == item.CODEID.ToString()).ToList();
                    if (data1.Count() > 0)
                    {
                        CategoryWiseItems obj  = new CategoryWiseItems();
                        List <ItemsList>  obj1 = new List <ItemsList>();
                        obj.CategoryId = data1.Select(x => x.CATEGORY_ID).FirstOrDefault();
                        obj.Name       = data1.Select(x => x.CATEGORY_NAME).FirstOrDefault();
                        foreach (var itemm in data1)
                        {
                            ItemsList obj2 = new ItemsList();
                            obj2.ITEM_ID          = itemm.ITEM_ID;
                            obj2.ITEM_DESCRIPTION = itemm.ITEM_DESCRIPTION;
                            obj2.ITEM_PRICE       = itemm.ITEM_PRICE;
                            obj2.ITEM_PHOTO       = itemm.ITEM_PHOTO;
                            obj2.ITEM_UNIT        = itemm.ITEM_UNIT;
                            obj2.ITEM_QUANTITY    = itemm.ITEM_QUANTITY;
                            obj1.Add(obj2);
                        }
                        obj.subCategories = obj1;
                        subCategories.Add(obj);
                    }
                }

                var routData = new CATEGOR_LIST
                {
                    STATUS_CODE   = 200,
                    MESSAGE       = "Success",
                    CATEGORY_LIST = subCategories
                };
                json = JsonConvert.SerializeObject(routData, Formatting.Indented);
            }
            catch (Exception ex)
            {
                var routData = new CMNObject
                {
                    STATUS_CODE = 401,
                    MESSAGE     = ex.Message
                };
                json = JsonConvert.SerializeObject(routData, Formatting.Indented);
            }
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Buffer          = true;
            HttpContext.Current.Response.Charset         = "UTF-8";
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
            HttpContext.Current.Response.ContentType     = "application/json";
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }