Exemplo n.º 1
0
        public DtoTblCountry(TblCountry country, HttpStatusCode statusEffect)
        {
            id   = country.id;
            Name = country.Name;

            StatusEffect = statusEffect;
        }
Exemplo n.º 2
0
        public async Task <TblCountry> AddCountry(TblCountry country)
        {
            HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync("api/CountryCore/AddCountry", country);

            TblCountry ans = await httpResponseMessage.Content.ReadAsAsync <TblCountry>();

            return(ans);
        }
Exemplo n.º 3
0
        public async Task <bool> UpdateCountry(TblCountry country, int logId)
        {
            List <object> countryAndLogId = new List <object>();

            countryAndLogId.Add(country);
            countryAndLogId.Add(logId);
            HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync("api/CountryCore/UpdateCountry", countryAndLogId);

            bool ans = await httpResponseMessage.Content.ReadAsAsync <bool>();

            return(ans);
        }
Exemplo n.º 4
0
        public IHttpActionResult AddCountry(TblCountry country)
        {
            var task = Task.Run(() => new CountryService().AddCountry(country));

            if (task.Wait(TimeSpan.FromSeconds(10)))
            {
                if (task.Result.id != -1)
                {
                    return(Ok(new DtoTblCountry(task.Result, HttpStatusCode.OK)));
                }
                else
                {
                    return(Conflict());
                }
            }
            return(StatusCode(HttpStatusCode.RequestTimeout));
        }
Exemplo n.º 5
0
 public static List<TblCountry> GetCountryListData(bool hasSelectAllRow)
 {
     List<TblCountry> list = new List<TblCountry>();
     var jss = new JavaScriptSerializer();
     var dict = jss.Deserialize<dynamic>(BizDictionary.GetCountryListJS());
     TblCountry allRow = new TblCountry();
     allRow.Name = "Все";
     allRow.Id = -1;
     if (hasSelectAllRow)
         list.Add(allRow);
     foreach (var itm in dict) {
         TblCountry tbl = new TblCountry();
         tbl.Id = itm["Id"];
         tbl.Name = itm["Name"];
         tbl.Description = itm["Description"];
         list.Add(tbl);
     }
     return list;
 }
Exemplo n.º 6
0
        public IHttpActionResult UpdateCountry(List <object> countryLogId)
        {
            TblCountry country = JsonConvert.DeserializeObject <TblCountry>(countryLogId[0].ToString());
            int        logId   = JsonConvert.DeserializeObject <int>(countryLogId[1].ToString());
            var        task    = Task.Run(() => new CountryService().UpdateCountry(country, logId));

            if (task.Wait(TimeSpan.FromSeconds(10)))
            {
                if (task.Result)
                {
                    return(Ok(true));
                }
                else
                {
                    return(Conflict());
                }
            }
            return(StatusCode(HttpStatusCode.RequestTimeout));
        }
Exemplo n.º 7
0
 public bool UpdateCountry(TblCountry country, int logId)
 {
     return(new MainProvider().Update(country, logId));
 }
Exemplo n.º 8
0
 public TblCountry AddCountry(TblCountry country)
 {
     return((TblCountry) new MainProvider().Add(country));
 }
 public TblCountry AddCountry(TblCountry country)
 {
     return(new CountryRepo().AddCountry(country));
 }
 public bool UpdateCountry(TblCountry country, int logId)
 {
     return(new CountryRepo().UpdateCountry(country, logId));
 }
Exemplo n.º 11
0
        public static String AddLoc(String Loc, string Latude, string Path, string TypeID, string ParentID, string Population)
        {
            //  string myret = Fn.Exec("insert into " + getTblName(TypeID) + " (LocName,Lat,Path," + getTblName(TypeID).ToUpper().Replace("TBL", "") + "ID) values('" + Loc + "','" + Latude + "','" + Path + "'," + ParentID + ")");
            // return myret;
            ///8888888888888888888888888888888888888888888888888TypeID

            switch (TypeID)
            {
            case "1":
                // return "tblCountry";
                using (DBDataContext db = new DBDataContext())
                {
                    if (db.TblCountries.Where(v => v.LocName.ToUpper().Trim() == Loc.ToUpper().Trim()).Count() > 0)
                    {
                        return("-1");
                    }

                    else
                    {
                        TblCountry tbl = new TblCountry();
                        tbl.LocName   = Loc;
                        tbl.Latitude  = Latude;
                        tbl.Path      = Path;
                        tbl.Lat       = Latude;
                        tbl.Longitude = Latude;
                        db.TblCountries.InsertOnSubmit(tbl);
                        db.SubmitChanges();
                        return("1");
                    }
                }

            case "2":
                //return "TblProvince";
                using (DBDataContext db = new DBDataContext())
                {
                    if (db.TblProvinces.Where(v => v.LocName.ToUpper().Trim() == Loc.ToUpper().Trim() && v.CountryID == Convert.ToInt32(ParentID)).Count() > 0)
                    {
                        return("-1");
                    }
                }

                return(Fn.Exec("insert into " + getTblName(TypeID) + " (LocName,Lat,Path," + getTblName(Convert.ToString(Convert.ToInt32(TypeID) - 1)).ToUpper().Replace("TBL", "") + "ID) values('" + Loc + "','" + Latude + "','" + Path + "'," + ParentID + ")"));

            case "3":
                //return "TblRegion";
                using (DBDataContext db = new DBDataContext())
                {
                    if (db.TblRegions.Where(v => v.LocName.ToUpper().Trim() == Loc.ToUpper().Trim() && v.ProvinceID == Convert.ToInt32(ParentID)).Count() > 0)
                    {
                        return("-1");
                    }
                }
                return(Fn.Exec("insert into " + getTblName(TypeID) + " (LocName,Lat,Path," + getTblName(Convert.ToString(Convert.ToInt32(TypeID) - 1)).ToUpper().Replace("TBL", "") + "ID) values('" + Loc + "','" + Latude + "','" + Path + "'," + ParentID + ")"));

            case "4":
                // return "TblDistrict";
                using (DBDataContext db = new DBDataContext())
                {
                    if (db.TblDistricts.Where(v => v.LocName.ToUpper().Trim() == Loc.ToUpper().Trim()).Count() > 0)
                    {
                        return("-1");
                    }
                }
                return(Fn.Exec("insert into " + getTblName(TypeID) + " (LocName,Lat,Path," + getTblName(Convert.ToString(Convert.ToInt32(TypeID) - 1)).ToUpper().Replace("TBL", "") + "ID) values('" + Loc + "','" + Latude + "','" + Path + "'," + ParentID + ")"));

            case "5":
                // return "TblTehsil";

                using (DBDataContext db = new DBDataContext())
                {
                    if (db.TblTehsils.Where(v => v.LocName.ToUpper().Trim() == Loc.ToUpper().Trim() && v.DistrictID == Convert.ToInt32(ParentID)).Count() > 0)
                    {
                        return("-1");
                    }
                }
                return(Fn.Exec("insert into " + getTblName(TypeID) + " (LocName,Lat,Path," + getTblName(Convert.ToString(Convert.ToInt32(TypeID) - 1)).ToUpper().Replace("TBL", "") + "ID) values('" + Loc + "','" + Latude + "','" + Path + "'," + ParentID + ")"));

            case "6":
                // return "TblFeildUnit";
                using (DBDataContext db = new DBDataContext())
                {
                    if (db.TblFeildUnits.Where(v => v.LocName.ToUpper().Trim() == Loc.ToUpper().Trim() && v.TehsilID == Convert.ToInt32(ParentID)).Count() > 0)
                    {
                        return("-1");
                    }
                }
                return(Fn.Exec("insert into " + getTblName(TypeID) + " (LocName,Lat,Path," + getTblName(Convert.ToString(Convert.ToInt32(TypeID) - 1)).ToUpper().Replace("TBL", "") + "ID) values('" + Loc + "','" + Latude + "','" + Path + "'," + ParentID + ")"));

            case "7":
                // return "TblUnionConcil";
                using (DBDataContext db = new DBDataContext())
                {
                    if (db.TblUnionConcils.Where(v => v.LocName.ToUpper().Trim() == Loc.ToUpper().Trim() && v.FeildUnitID == Convert.ToInt32(ParentID)).Count() > 0)
                    {
                        return("-1");
                    }
                }
                return(Fn.Exec("insert into " + getTblName(TypeID) + " (LocName,Lat,Path," + getTblName(Convert.ToString(Convert.ToInt32(TypeID) - 1)).ToUpper().Replace("TBL", "") + "ID) values('" + Loc + "','" + Latude + "','" + Path + "'," + ParentID + ")"));

            case "8":
                //                    return "TblVillageCity";
                using (DBDataContext db = new DBDataContext())
                {
                    if (db.TblVillageCities.Where(v => v.LocName.ToUpper().Trim() == Loc.ToUpper().Trim() && v.UnionConcilID == Convert.ToInt32(ParentID)).Count() > 0)
                    {
                        return("-1");
                    }
                }
                return(Fn.Exec("insert into " + getTblName(TypeID) + " (LocName,Lat,Path,Population," + getTblName(Convert.ToString(Convert.ToInt32(TypeID) - 1)).ToUpper().Replace("TBL", "") + "ID) values('" + Loc + "','" + Latude + "','" + Path + "'," + Population + "," + ParentID + ")"));

            default:
                return("");
            }


            //var loca = db.s.Where(v => v.LocName.ToUpper() == Loc.ToUpper() && v.TypeID == Convert.ToInt32(TypeID)).FirstOrDefault();
            //if (loca != null)
            //{
            //    return "-1";
            //}
            //else
            //{
            //    return Fn.Exec("insert into  (LocName,Lat,Path,TypeID,ParentID) values('" + Loc + "','" + Latude + "','" + Path + "','" + TypeID + "'," + ParentID + ")");


            //}

            //}

            //return "";
        }