コード例 #1
0
        public HttpResponseMessage Productid(GetPid getPid)
        {
            try
            {
                //-------------------   API Hit Count  ----------------------------------

                db.RequestHit("BrandAPI", 1);

                List <Product> Prod;
                using (FFGSPL_dbEntities edb = new FFGSPL_dbEntities())
                {
                    //---------------   Deserialization of JsonResult   -----------------

                    string id  = JsonConvert.SerializeObject(getPid.Pid);
                    var    u   = JsonConvert.DeserializeObject(id);
                    int    Pid = Convert.ToInt32(u);

                    var data = from B in edb.Product_tbl.Where(x => x.pr_id == Pid)
                               select new Product()
                    {
                        Productid    = B.pr_id,
                        Product_name = B.pr_name
                    };

                    Prod = data.ToList();
                }

                return(new HttpResponseMessage()
                {
                    Content = new JsonContent(new
                    {
                        Status = "Success",
                        Product = Prod  //return exception
                    })
                });
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage()
                {
                    Content = new JsonContent(new
                    {
                        Status = "Fail",
                        Error = ex.Message  //return exception
                    })
                });
            }
        }
コード例 #2
0
        public HttpResponseMessage Brandid(GetBid getBid)
        {
            try
            {
                //-------------------   API Hit Count  ----------------------------------

                db.RequestHit("BrandAPI", 1);

                List <Brand> Bran;
                using (FFGSPL_dbEntities edb = new FFGSPL_dbEntities())
                {
                    //---------------   Deserialization of JsonResult   -----------------

                    string id  = JsonConvert.SerializeObject(getBid.Bid);
                    var    u   = JsonConvert.DeserializeObject(id);
                    int    Bid = Convert.ToInt32(u);

                    var data = from B in edb.Brand_tbl.Where(x => x.br_id == Bid)
                               select new Brand()
                    {
                        Brandid    = B.br_id,
                        Brand_name = B.br_name
                    };

                    Bran = data.ToList();
                }

                return(new HttpResponseMessage()
                {
                    Content = new JsonContent(new
                    {
                        Status = "Success",
                        Brands = Bran  //return exception
                    })
                });
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage()
                {
                    Content = new JsonContent(new
                    {
                        Status = "Fail",
                        Error = ex.Message  //return exception
                    })
                });
            }
        }
コード例 #3
0
        public HttpResponseMessage BrandAll()
        {
            try
            {
                //-------------------   API Hit Count  ----------------------------------

                db.RequestHit("BrandAPI", 1);

                List <Brand> Bran;
                using (FFGSPL_dbEntities edb = new FFGSPL_dbEntities())
                {
                    var data = from B in edb.Brand_tbl
                               select new Brand()
                    {
                        Brandid    = B.br_id,
                        Brand_name = B.br_name
                    };

                    Bran = data.ToList();
                }

                return(new HttpResponseMessage()
                {
                    Content = new JsonContent(new
                    {
                        Status = "Success",
                        Brands = Bran  //return exception
                    })
                });
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage()
                {
                    Content = new JsonContent(new
                    {
                        Status = "Fail",
                        Error = ex.Message  //return exception
                    })
                });
            }
        }
コード例 #4
0
        public HttpResponseMessage ProductAll()
        {
            try
            {
                List <Product> Prod;
                using (FFGSPL_dbEntities edb = new FFGSPL_dbEntities())
                {
                    //API Hit Count
                    edb.RequestHit("ProductAPI", 1);

                    var data = from B in edb.Product_tbl
                               select new Product()
                    {
                        Productid    = B.pr_id,
                        Product_name = B.pr_name
                    };

                    Prod = data.ToList();
                }

                return(new HttpResponseMessage()
                {
                    Content = new JsonContent(new
                    {
                        Status = "Success",
                        Products = Prod  //return exception
                    })
                });
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage()
                {
                    Content = new JsonContent(new
                    {
                        Status = "Fail",
                        Error = ex.Message  //return exception
                    })
                });
            }
        }
コード例 #5
0
        public HttpResponseMessage UserDetails(User_t jsonResult)
        {
            try
            {
                //---------------   API Hits    -------------------------------------

                db.RequestHit("LoginAPI", 1);

                //---------------   Deserialization of JsonResult   -----------------

                string email    = JsonConvert.SerializeObject(jsonResult.User);
                string pass     = JsonConvert.SerializeObject(jsonResult.Pass);
                var    u        = JsonConvert.DeserializeObject(email);
                var    p        = JsonConvert.DeserializeObject(pass);
                string username = u.ToString();
                string password = p.ToString();


                if (IsValidUser(username, password))
                {
                    using (FFGSPL_dbEntities edb = new FFGSPL_dbEntities())
                    {
                        User_d[] udata;

                        string user = u.ToString();

                        var data = db.User_Data(user).Select(x => new User_d
                        {
                            Userid      = x.User_id,
                            Firstname   = x.User_Firstname,
                            Lastname    = x.User_Lastname,
                            Mobile      = x.User_Mobile,
                            Email       = x.User_Email,
                            Entity      = x.Entity,
                            Designation = x.User_Designation
                        });
                        udata = data.ToArray();

                        //------------- Convert Data to Json ------------------

                        return(new HttpResponseMessage()
                        {
                            Content = new JsonContent(new
                            {
                                Status = "Success",
                                User_Data = udata  //return data
                            })
                        });
                    }
                }
                else
                {
                    return(new HttpResponseMessage()
                    {
                        Content = new JsonContent(new
                        {
                            Status = "Fail",
                            Error = "Username or Password is Incorret!!"  //return exception
                        })
                    });
                }
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage()
                {
                    Content = new JsonContent(new
                    {
                        Status = "Fail",
                        Error = ex.Message  //return exception
                    })
                });
            }
        }
コード例 #6
0
        public HttpResponseMessage Fran_Data(Frn_id jsonResult)
        {
            try
            {
                //---------------   API Hits    -------------------------------------

                db.RequestHit("FDataAPI", 1);

                //---------------   Deserialization of JsonResult   -----------------

                string id  = JsonConvert.SerializeObject(jsonResult.Fid);
                var    u   = JsonConvert.DeserializeObject(id);
                int    fid = Convert.ToInt32(u);

                if (fid >= 0)
                {
                    Franchise_Data[] Data;
                    using (FFGSPL_dbEntities edb = new FFGSPL_dbEntities())
                    {
                        var data = db.Fran_Data(fid).Select(y => new Franchise_Data
                        {
                            Fran_id           = y.Franchise_Id,
                            Franchise_name    = y.Franchise_Name,
                            Visited_date      = Convert.ToDateTime(y.Visited_Date),
                            Brand             = y.Brand,
                            Product           = y.Product,
                            Owner_Manager     = y.Owner___Manager,
                            Mobile            = y.Mobile_Number,
                            Email             = y.Email_ID,
                            Landline          = y.Email_ID,
                            Address           = y.Address,
                            Pincode           = y.Pincode.Value,
                            Area              = y.Area,
                            City              = y.City,
                            State             = y.State,
                            Location_lat      = y.Lattitude,
                            Location_lng      = y.Longtuide,
                            No_tech_work      = y.Number_of_Techinican_Working.Value,
                            Req_jan           = y.Januery.Value,
                            Req_feb           = y.Frbruary.Value,
                            Req_mar           = y.March.Value,
                            Req_apr           = y.April.Value,
                            Req_may           = y.May.Value,
                            Req_jun           = y.June.Value,
                            Req_jul           = y.July.Value,
                            Req_aug           = y.August.Value,
                            Req_sept          = y.September.Value,
                            Req_oct           = y.October.Value,
                            Req_nov           = y.November.Value,
                            Req_dec           = y.December.Value,
                            Sal_Range_Fresher = y.Salary_Range_for_Freshers.Value,
                            Contact_person    = y.Contact_Person_Name,
                            Contact_Number    = y.Contact_Number
                        });



                        Data = data.ToArray();
                    }
                    return(new HttpResponseMessage()
                    {
                        Content = new JsonContent(new
                        {
                            Status = "Success",
                            Fran_Data = Data  //return data
                        })
                    });
                }

                else
                {
                    return(new HttpResponseMessage()
                    {
                        Content = new JsonContent(new
                        {
                            Status = "Fail",
                            Error = "Franchise ID Does not exist!!"  //return exception
                        })
                    });
                }
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage()
                {
                    Content = new JsonContent(new
                    {
                        Status = "Fail",
                        Error = ex.Message  //return exception
                    })
                });
            }
        }
コード例 #7
0
        public HttpResponseMessage User_Data(User_id jsonResult)
        {
            try
            {
                //---------------   API Hits    -------------------------------------

                db.RequestHit("UDataAPI", 1);

                //---------------   Deserialization of JsonResult   -----------------

                string id  = JsonConvert.SerializeObject(jsonResult.Uid);
                var    u   = JsonConvert.DeserializeObject(id);
                int    uid = Convert.ToInt32(u);

                if (uid >= 0)
                {
                    Franchise_List[] Data;
                    using (FFGSPL_dbEntities edb = new FFGSPL_dbEntities())
                    {
                        var data = db.FranCount_Data(uid).Select(y => new Franchise_List
                        {
                            Fran_id        = y.Franchise_ID,
                            Franchise_name = y.Franchise_Name,
                            Visited_date   = y.Visited_Date.Value.Date,
                            //Brand = y.Brand,
                            //Product = y.Product,
                            //Owner_Manager = y.Owner_Manager,
                            //Mobile = y.Mobile_Number,
                            //Email = y.EmailID,
                            //Landline = y.Landline,
                            //Address = y.Address,
                            //Pincode = y.Pincode.Value,
                            Area = y.Area,
                            City = y.City,
                            //State = y.State,
                            //Location_lat = y.Lattitute,
                            //Location_lng = y.Longitude,
                            //No_tech_work = y.Number_of_Techinican_Working.Value,
                            //Req_jan = y.Januery.Value,
                            //Req_feb = y.Frbruary.Value,
                            //Req_mar = y.March.Value,
                            //Req_apr = y.April.Value,
                            //Req_may = y.May.Value,
                            //Req_jun = y.June.Value,
                            //Req_jul = y.July.Value,
                            //Req_aug = y.August.Value,
                            //Req_sept = y.September.Value,
                            //Req_oct = y.October.Value,
                            //Req_nov = y.November.Value,
                            //Req_dec = y.December.Value,
                            //Sal_Range_Fresher = y.Salary_Range_for_Freshers.Value,
                            //Contact_person = y.Contact_PersonName,
                            //Contact_Number = y.Contact_Number,
                            CurrentMonthCount = y.CurrentMonthCount.Value,
                            Officer_id        = uid.ToString()
                        });



                        Data = data.ToArray();
                    }
                    return(new HttpResponseMessage()
                    {
                        Content = new JsonContent(new
                        {
                            Status = "Success",
                            User_Data = Data  //return data
                        })
                    });
                }

                else
                {
                    return(new HttpResponseMessage()
                    {
                        Content = new JsonContent(new
                        {
                            Status = "Fail",
                            Error = "Username ID Does not exist!!"  //return exception
                        })
                    });
                }
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage()
                {
                    Content = new JsonContent(new
                    {
                        Status = "Fail",
                        Error = ex.Message  //return exception
                    })
                });
            }
        }