Exemple #1
0
        public IHttpActionResult GettblCity(int id)
        {
            //tblCity tblCity = db.tblCities.Find(id);
            //if (tblCity == null)
            //{
            //    return NotFound();
            //}
            //return Ok(tblCity);

            var data = db.tblCities.Where(w => w.ID == id).FirstOrDefault();

            if (data == null)
            {
                return(Ok(new { code = 1, data = "Not found" }));
            }
            else
            {
                tblCity model = new tblCity();
                model.ID        = data.ID;
                model.Name      = data.Name;
                model.StateID   = data.StateID;
                model.Created   = System.DateTime.Now;
                model.CreatedBy = data.CreatedBy;
                model.Updated   = System.DateTime.Now;
                model.UpdatedBy = data.UpdatedBy;
                model.Active    = Convert.ToBoolean(data.Active);

                return(Ok(new { code = 0, data = model }));
            }
        }
Exemple #2
0
        public IHttpActionResult PuttblCity(int id, tblCity tblCity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tblCity.Id)
            {
                return(BadRequest());
            }

            db.Entry(tblCity).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tblCityExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #3
0
 private bool SaveData()
 {
     objCommon = new clsCommon();
     if (objCommon.IsRecordExists("tblCity", tblCity.ColumnNames.AppCity, tblCity.ColumnNames.AppCityID, txtCity.Text, hdnPKID.Value))
     {
         DInfo.ShowMessage("City already exits.", Enums.MessageType.Error);
         return(false);
     }
     objCommon = null;
     objCity   = new tblCity();
     if (!string.IsNullOrEmpty(hdnPKID.Value) && hdnPKID.Value != "")
     {
         objCity.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value));
     }
     else
     {
         objCity.AddNew();
     }
     objCity.AppCity      = txtCity.Text;
     objCity.s_AppStateID = ddlState.SelectedValue.ToString();
     objCity.Save();
     iCityID = objCity.AppStateID;
     objCity = null;
     return(true);
 }
Exemple #4
0
    private bool Delete(int intPKID)
    {
        bool retval = false;

        objState = new tblState();
        tblCity objCity = new tblCity();

        if (objState.LoadByPrimaryKey(intPKID))
        {
            objCity.Where.AppStateID.Value = intPKID;
            objCity.Query.Load();
            if (objCity.RowCount > 0)
            {
                retval = false;
            }
            else
            {
                objState.MarkAsDeleted();
                objState.Save();
                retval = true;
            }
        }
        objCity  = null;
        objState = null;
        return(retval);
    }
Exemple #5
0
 private void SetValuesToControls()
 {
     if (!string.IsNullOrEmpty(hdnPKID.Value) && hdnPKID.Value != "")
     {
         objPinCode = new tblPinCode();
         if (objPinCode.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value)))
         {
             txtPINCode.Text     = objPinCode.AppPinCode.ToString();
             chkIsActive.Checked = objPinCode.AppIsActive;
             tblCity objCity = new tblCity();
             if (objCity.LoadByPrimaryKey(objPinCode.AppCityID))
             {
                 objCommon = new clsCommon();
                 tblState objState = new tblState();
                 if (objState.LoadByPrimaryKey(objCity.AppStateID))
                 {
                     ddlCountry.SelectedValue = objState.s_AppCountryID;
                     objCommon.FillDropDownList(ddlState, "tblState", tblState.ColumnNames.AppState, tblState.ColumnNames.AppStateID, "-- Select State --", tblState.ColumnNames.AppCountryID + "=" + ddlCountry.SelectedValue);
                     ddlState.SelectedValue = objState.s_AppStateID;
                     objCommon.FillDropDownList(ddlCity, "tblCity", tblCity.ColumnNames.AppCity, tblCity.ColumnNames.AppCityID, "-- Select City --", tblCity.ColumnNames.AppStateID + "=" + ddlState.SelectedValue);
                     ddlCity.SelectedValue = objCity.s_AppCityID;
                 }
                 objState  = null;
                 objCommon = null;
             }
             objCity = null;
         }
         objPinCode = null;
     }
 }
Exemple #6
0
        // GET: /Users/
        public ActionResult Index(int isdelete = 0, int restoreid = 0)
        {
            var list = (dynamic)null;

            TempData["restore"] = "";
            if (isdelete == 0)
            {
                if (restoreid > 0)
                {
                    if (db.tblCity.Any(a => a.CityID == restoreid && a.IsDelete == true))
                    {
                        tblCity tblCity = db.tblCity.Find(restoreid);
                        tblCity.IsDelete        = false;
                        db.Entry(tblCity).State = EntityState.Modified;
                        db.SaveChanges();
                        TempData["msg"] = "Record Restore Successfully";
                        // return View("Index","City");
                    }
                }
                list = db.tblCity.Where(a => a.IsDelete != true).OrderByDescending(a => a.CityID).ToList();
            }
            else
            {
                TempData["restore"] = "restore";
                list = db.tblCity.Where(a => a.IsDelete == true).OrderByDescending(a => a.CityID).ToList();
            }
            return(View(list));
        }
        public ActionResult AddCity(string jsonData)
        {
            SPResponse result      = new SPResponse();
            var        userDetails = (CustomerLoginDetail)Session["UserSession"];
            string     CityId      = "";

            try
            {
                JavaScriptSerializer json_serializer = new JavaScriptSerializer();
                json_serializer.MaxJsonLength = int.MaxValue;
                object[] objData = (object[])json_serializer.DeserializeObject(jsonData);
                tblCity  objcity = new tblCity();
                foreach (Dictionary <string, object> item in objData)
                {
                    objcity.CityName    = Convert.ToString(item["cityNm"]);
                    objcity.CreatedBy   = userDetails.LoginId;
                    objcity.CreatedDate = DateTime.Now;
                    CityId           = Convert.ToString(item["CityId"]);
                    objcity.IsActive = Convert.ToBoolean(item["IsActive"]);
                    if (CityId != "")
                    {
                        objcity.CityId = Convert.ToInt32(CityId);
                    }
                    else
                    {
                    }
                }
                result = COR.AddCity(objcity);
            }
            catch (Exception ex)
            {
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #8
0
    void cmbRegion_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        try
        {
            cmbCity.Items.Clear();
            cmbCity.Items.Add(new RadComboBoxItem("[Select City]", "-1"));
            cmbCity.AppendDataBoundItems = true;
            cmbCity.DataSource           = GoProGo.Business.Lookup.Geo.GetCitiesByRegionID(int.Parse(cmbRegion.SelectedItem.Value));
            cmbCity.DataTextField        = "City";
            cmbCity.DataValueField       = "ID";
            cmbCity.DataBind();

            if (!IsPostBack)
            {
                tblCity city = GoProGoDC.GeoDC.GetCityByRegionAndCity(int.Parse(cmbRegion.SelectedItem.Value), UserBrowsingInfo.City).SingleOrDefault <tblCity>();
                if (city != null)
                {
                    cmbCity.SelectedValue = city.ID.ToString();
                }
                else
                {
                    cmbCategory.SelectedIndex = 0;
                }
                //TODO: Log this situation
                //throw new Exception("City can not be null.");
            }
        }
        catch (Exception ex)
        {
            ThrowError(this, new ControlErrorArgs()
            {
                InnerException = ex, Message = ex.Message, Severity = 1
            });
        }
    }
Exemple #9
0
        public SPResponse ActiveInactiveCity(int CityId)
        {
            tblCity    objcity = new tblCity();
            SPResponse result  = new SPResponse();

            using (var context = new CommonDBContext())
            {
                objcity = context.tblCities.Where(x => x.CityId == CityId).FirstOrDefault();

                if (objcity.IsActive == true)
                {
                    objcity.IsActive = false;
                }
                else
                {
                    objcity.IsActive = true;
                }

                context.tblCities.AddOrUpdate(objcity);
                context.SaveChanges();
                result.ResponseCode    = "00";
                result.ResponseMessage = "City Updated Successfully";
            }
            return(result);
        }
Exemple #10
0
 public int Save(tblCity tbl)
 {
     tbl.IsDelete = false;
     objData.tblCities.Add(tbl);
     objData.SaveChanges();
     return(tbl.CityId.Value);
 }
        public async Task <IActionResult> Edit(int id, [Bind("city_Id,state_Id,City")] tblCity tblCity)
        {
            if (id != tblCity.city_Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tblCity);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!tblCityExists(tblCity.city_Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["state_Id"] = new SelectList(_context.tblState, "state_Id", "State", tblCity.state_Id);
            return(View(tblCity));
        }
Exemple #12
0
        /// <summary>
        /// Action Methods To Be Used By JQuery Ajax
        /// </summary>


        public ActionResult GetCityList()
        {
            if (Session["AdminUser"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

            List <tblCity> cityList = new List <tblCity>();

            foreach (tblCity city in db.tblCities.Include(c => c.tblState.tblCountry).ToList())
            {
                tblCity objCity = new tblCity();
                objCity.CityId     = city.CityId;
                objCity.CityName   = city.CityName;
                objCity.IsActive   = city.IsActive;
                objCity.CountryId  = city.CountryId;
                objCity.StateId    = city.StateId;
                objCity.tblCountry = new tblCountry()
                {
                    CountryId = city.CountryId, CountryName = city.tblCountry.CountryName
                };
                objCity.tblState = new tblState()
                {
                    StateId = city.StateId, StateName = city.tblState.StateName
                };

                cityList.Add(objCity);
            }
            return(Json(cityList, JsonRequestBehavior.AllowGet));
        }
        public string ChangeStatus(long id)
        {
            tblCity user = _dbRepository.SelectById(id);

            user.IsActive = !user.IsActive;
            return(_dbRepository.Update(user));
        }
Exemple #14
0
    private bool Delete(int intPKID)
    {
        bool retval = false;

        objCity = new tblCity();
        tblPinCode objPINCode = new tblPinCode();

        if (objCity.LoadByPrimaryKey(intPKID))
        {
            objPINCode.Where.AppCityID.Value = intPKID;
            objPINCode.Query.Load();
            if (objPINCode.RowCount > 0)
            {
                retval = false;
            }
            else
            {
                objCity.MarkAsDeleted();
                objCity.Save();
                retval = true;
            }
        }
        objPINCode = null;
        objCity    = null;
        return(retval);
    }
Exemple #15
0
        public bool InsertCity(CityModel cityModel)
        {
            try
            {
                tblCity entity = new tblCity();
                entity = _unitOfWork.CityRepository.Get(filter: prop => prop.CityName.Equals(cityModel.CityName)).FirstOrDefault();
                Guid newGuid = Guid.NewGuid();
                if (entity == null)
                {
                    tblCity city = new tblCity()
                    {
                        CityID   = newGuid,
                        CityName = cityModel.CityName,
                        StateID  = cityModel.StateID
                    };
                    _unitOfWork.CityRepository.Insert(city);
                    _unitOfWork.Save();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                string currentFile = new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                ErrorLogger.LogException(e, currentFile);

                return(false);
            }
        }
Exemple #16
0
        public ActionResult DeleteConfirmed(int id)
        {
            tblCity tblCity = db.tblCities.Find(id);

            db.tblCities.Remove(tblCity);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #17
0
        public bool DeleteCityLogic(Guid cityGuid)
        {
            tblCity city = bringlyEntities.tblCities.Where(c => c.CityGuid == cityGuid).FirstOrDefault();

            city.IsDeleted = true;
            bringlyEntities.SaveChanges();
            return(true);
        }
Exemple #18
0
        public ActionResult UpdateCity(tblCity c)
        {
            tblCity result = db.tblCities.Single(city => city.CityId == c.CityId);

            result.CityName = c.CityName;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #19
0
        public int DeleteCityDetails(int cityId)
        {
            tblCity city = db.tblCities.Find(cityId);

            db.tblCities.Remove(city);

            return(db.SaveChanges());
        }
Exemple #20
0
        public IHttpActionResult PuttblCity(tblCity tblCity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            //if (id != tblCity.ID)
            //{
            //    return BadRequest();
            //}
            //db.Entry(tblCity).State = EntityState.Modified;
            //try
            //{
            //    db.SaveChanges();
            //}
            //catch (DbUpdateConcurrencyException)
            //{
            //    if (!tblCityExists(id))
            //    {
            //        return NotFound();
            //    }
            //    else
            //    {
            //        throw;
            //    }
            //}
            //return StatusCode(HttpStatusCode.NoContent);

            if (tblCity == null)
            {
                throw new ArgumentNullException("tblCity");
            }

            var data = db.tblCities.Where(w => w.ID == tblCity.ID).Count();//.FirstOrDefault();

            if (data >= 0)
            {
                tblCity city = new tblCity();
                city.ID        = tblCity.ID;
                city.StateID   = tblCity.StateID;
                city.Name      = tblCity.Name;
                city.Created   = System.DateTime.Now;
                city.CreatedBy = tblCity.CreatedBy;
                city.Updated   = System.DateTime.Now;
                city.UpdatedBy = tblCity.UpdatedBy;
                city.Active    = Convert.ToBoolean(tblCity.Active);

                db.Entry(city).State = EntityState.Modified;
                db.SaveChanges();

                return(Ok(new { code = 0, data = "City updated successfully." }));
            }
            else
            {
                return(Ok(new { code = 1, data = "City not found." }));
            }
        }
Exemple #21
0
        internal void Update(tblCity model)
        {
            tblCity newobj = objData.tblCities.Where(p => p.CityId == model.CityId && p.IsDelete == false).FirstOrDefault();

            newobj.CityName = model.CityName;
            newobj.StateId  = model.StateId;
            newobj.Pincode  = model.Pincode;
            objData.SaveChanges();
        }
Exemple #22
0
 public ActionResult Create([Bind(Include = "CityID,CityName,CreatedBy,UpdatedBy,CreateDate,UpdateDate,IsLogin,IsDelete,IsActive,CountryID,ProvinceID,DeleteBy,DeleteDate")] tblCity tblCity)
 {
     if (ModelState.IsValid)
     {
         db.tblCity.Add(tblCity);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblCity));
 }
Exemple #23
0
        public void Delete()
        {
            using (WorkWithMeDataContext oDC = new WorkWithMeDataContext())
            {
                tblCity city = (from c in oDC.tblCities where c.Id == Id select c).FirstOrDefault();

                oDC.tblCities.DeleteOnSubmit(city);
                oDC.SubmitChanges();
            }
        }
Exemple #24
0
        public tblCity GetCityById(int CityId)
        {
            tblCity objcity = new tblCity();

            using (var context = new CommonDBContext())
            {
                objcity = context.tblCities.Where(x => x.CityId == CityId).FirstOrDefault();
            }
            return(objcity);
        }
Exemple #25
0
 public ActionResult Edit([Bind(Include = "ID,Name")] tblCity tblCity)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblCity).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblCity));
 }
Exemple #26
0
        public SavingResult SaveNewRecord(tblCity SaveModel)
        {
            SavingResult res = new SavingResult();

            //-- Perform Validation
            //res.ExecutionResult = eExecutionResult.ValidationError;
            //res.ValidationError = "Validation error message";
            //return res;

            //--
            using (dbVisionEntities db = new dbVisionEntities())
            {
                //tblCity SaveModel;
                if (SaveModel.CityName == "")
                {
                    res.ValidationError = "Can not accept blank value. Please enter City Name.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }
                else if (IsDuplicateRecord(SaveModel.CityName, SaveModel.CityID, SaveModel.StateID, db))
                {
                    res.ValidationError = "Can not accept duplicate value. The City Name is already exists.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }

                SaveModel.CountryID = db.tblStates.FirstOrDefault(r => r.StateID == SaveModel.StateID).CountryID;
                if (SaveModel.CityID == 0) // New Entry
                {
                    SaveModel.rcuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID;
                    SaveModel.rcdt  = DateTime.Now;
                    db.tblCities.Add(SaveModel);
                }
                else
                {
                    SaveModel.reuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID;
                    SaveModel.redt  = DateTime.Now;
                    db.tblCities.Attach(SaveModel);
                    db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified;
                }

                //--
                try
                {
                    db.SaveChanges();
                    res.PrimeKeyValue   = SaveModel.CityID;
                    res.ExecutionResult = eExecutionResult.CommitedSucessfuly;
                }
                catch (Exception ex)
                {
                    CommonFunctions.GetFinalError(res, ex);
                }
            }
            return(res);
        }
Exemple #27
0
        public ActionResult Create([Bind(Include = "ID,Name")] tblCity tblCity)
        {
            if (ModelState.IsValid)
            {
                db.tblCities.Add(tblCity);
                db.SaveChanges();
                return(RedirectToAction("Create", "Locals"));
            }

            return(View(tblCity));
        }
Exemple #28
0
        public string GetCity(Guid cityId)
        {
            using (WorkWithMeDataContext oDC = new WorkWithMeDataContext())
            {
                tblCity city = (from c in oDC.tblCities where c.Id == Id select c).FirstOrDefault();

                CityName = city.CityName;

                return(CityName);
            }
        }
Exemple #29
0
        public bool IsCityExists(City city)
        {
            bool    cityexists = false;
            tblCity cityObject = bringlyEntities.tblCities.Where(x => x.IsDeleted == false && x.CityName == city.CityName && x.CityGuid != city.CityGuid).FirstOrDefault();

            if (cityObject != null && !string.IsNullOrEmpty(cityObject.CityName))
            {
                cityexists = true;
            }
            return(cityexists);
        }
Exemple #30
0
        public ActionResult Delete(int?id)
        {
            tblCity   C = db.tblCities.SingleOrDefault(x => x.intCityId == id);
            CityModel N = new CityModel()
            {
                CityId   = C.intCityId,
                CityName = C.strCityName,
            };

            return(View(N));
        }
Exemple #31
0
 /// <summary>
 /// Create a new tblCity object.
 /// </summary>
 /// <param name="cityID">Initial value of CityID.</param>
 public static tblCity CreatetblCity(short cityID)
 {
     tblCity tblCity = new tblCity();
     tblCity.CityID = cityID;
     return tblCity;
 }
Exemple #32
0
 /// <summary>
 /// There are no comments for tblCity in the schema.
 /// </summary>
 public void AddTotblCity(tblCity tblCity)
 {
     base.AddObject("tblCity", tblCity);
 }