public string DeleteLocality(int id, string status)
        {
            object result    = null;
            string strReturn = string.Empty;

            try
            {
                etblLocality obj = new etblLocality();
                obj           = BL_Locality.GetSingleRecordById(id);
                obj.cStatus   = status;
                obj.iActionBy = ((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId;
                int i = BL_Locality.UpdateRecord(obj);
                if (i == 1)
                {
                    result = new { st = 1, msg = clsUtils.ErrorMsg("Locality", 4, status) };
                }
                else
                {
                    result = new { st = 0, msg = clsUtils.ErrorMsg("Locality", 0) };
                }
            }
            catch (Exception)
            {
                result = new { st = 0, msg = clsUtils.ErrorMsg("", 3) };
            }
            strReturn = OneFineRateAppUtil.clsUtils.ConvertToJson(result);
            return(strReturn);
        }
Exemple #2
0
        //Update a record
        public static int UpdateRecord(etblLocality eobj)
        {
            int retval = 0;

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                try
                {
                    int dbobj = (from s in db.tblLocalityMs.Where(u => u.iCountryId == eobj.iCountryId && u.iStateId == eobj.iStateId && u.iCityId == eobj.iCityId && u.iAreaId == eobj.iAreaId && u.sLocality == eobj.sLocality.Trim() && u.iLocalityId != eobj.iLocalityId)
                                 select new
                    {
                        s.iLocalityId,
                    }).Count();
                    if (dbobj > 0)
                    {
                        return(retval = 2);
                    }

                    OneFineRate.tblLocalityM obj = (OneFineRate.tblLocalityM)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblLocalityM());
                    db.tblLocalityMs.Attach(obj);
                    db.Entry(obj).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    retval = 1;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(retval);
        }
Exemple #3
0
        //Get Single Record
        public static etblLocality GetSingleRecordById(int id)
        {
            etblLocality eobj = new etblLocality();

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                var dbobj = db.tblLocalityMs.SingleOrDefault(u => u.iLocalityId == id);
                if (dbobj != null)
                {
                    eobj = (etblLocality)OneFineRateAppUtil.clsUtils.ConvertToObject(dbobj, eobj);
                }
            }
            return(eobj);
        }
        public string AddLocality(int countryid, int stateid, int cityid, int areaid, string localityname)
        {
            object result    = null;
            string strReturn = string.Empty;

            try
            {
                etblLocality eObj = new etblLocality();
                eObj.iCountryId   = countryid;
                eObj.iStateId     = stateid;
                eObj.iCityId      = cityid;
                eObj.iAreaId      = areaid;
                eObj.sLocality    = localityname;
                eObj.dtActionDate = DateTime.Now;
                eObj.cStatus      = "A";
                eObj.iActionBy    = ((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId;
                int i = BL_Locality.AddRecord(eObj);
                if (i == 1)
                {
                    result = new { st = 1, msg = clsUtils.ErrorMsg("Locality", 1) };
                }
                else if (i == 2)
                {
                    result = new { st = 0, msg = clsUtils.ErrorMsg("Locality", 0) };
                }
                else
                {
                    result = new { st = 0, msg = clsUtils.ErrorMsg("Locality", 3) };
                }
            }
            catch (Exception ex)
            {
                result = new { st = 0, msg = clsUtils.ErrorMsg("", 3) };
            }
            strReturn = OneFineRateAppUtil.clsUtils.ConvertToJson(result);
            return(strReturn);
        }
        public string UpdateLocality(int id, int countryid, int stateid, int cityid, int areaid, string localityname)
        {
            object result    = null;
            string strReturn = string.Empty;

            try
            {
                etblLocality obj = new etblLocality();
                obj            = BL_Locality.GetSingleRecordById(id);
                obj.iCountryId = countryid;
                obj.iStateId   = stateid;
                obj.iCityId    = cityid;
                obj.iAreaId    = areaid;
                obj.sLocality  = localityname;
                obj.iActionBy  = ((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId;
                int i = BL_Locality.UpdateRecord(obj);
                if (i == 1)
                {
                    result = new { st = 1, msg = clsUtils.ErrorMsg("Locality", 2) };
                }
                else if (i == 2)
                {
                    result = new { st = 0, msg = clsUtils.ErrorMsg("Locality", 0) };
                }
                else
                {
                    result = new { st = 0, msg = clsUtils.ErrorMsg("Locality", 1) };
                }
            }
            catch (Exception)
            {
                result = new { st = 0, msg = clsUtils.ErrorMsg("", 3) };
            }
            strReturn = OneFineRateAppUtil.clsUtils.ConvertToJson(result);
            return(strReturn);
        }