Ejemplo n.º 1
0
        public void UpdateLocation(TblLocation location)
        {
            TblLocation updateLocation = GetLocationbyId(location.LocationId);

            updateLocation.LocationName = location.LocationName;
            dbContext.SaveChanges();
        }
Ejemplo n.º 2
0
        public void DeleteLocation(int locationId)
        {
            TblLocation updateLocation = GetLocationbyId(locationId);

            updateLocation.isDeleted = true;
            dbContext.SaveChanges();
        }
        public async Task <IActionResult> PutTblLocation(int id, TblLocation tblLocation)
        {
            if (id != tblLocation.LocationId)
            {
                return(BadRequest());
            }

            _context.Entry(tblLocation).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TblLocationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <TblLocation> > PostTblLocation(TblLocation tblLocation)
        {
            _context.TblLocations.Add(tblLocation);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTblLocation", new { id = tblLocation.LocationId }, tblLocation));
        }
Ejemplo n.º 5
0
 public IActionResult PostTblContactOnlyLocation([FromBody] TblLocation nContactOnlyLocation)
 {
     if (nContactOnlyLocation != null)
     {
         var hasData = this.repository.InsertTblContactOnlyLocationToDataBase(nContactOnlyLocation);
         if (hasData != null)
         {
             return(new JsonResult(hasData, DefaultJsonSettings));
         }
     }
     return(new StatusCodeResult(500));
 }
Ejemplo n.º 6
0
 public IActionResult PutTblLocationToDataBase(int key, [FromBody] TblLocation uLocation)
 {
     if (uLocation != null)
     {
         var hasData = this.repository.UpdateTblLocationToDataBase(key, uLocation);
         if (hasData != null)
         {
             return(new JsonResult(hasData, DefaultJsonSettings));
         }
     }
     return(new StatusCodeResult(500));
 }
Ejemplo n.º 7
0
        private void cmbLocation_SelectionChangeCommitted(object sender, EventArgs e)
        {
            //if selected is valid, render location name in textbox. else, clear it
            if (Convert.ToInt32(cmbLocation.SelectedValue) != 0)
            {
                TblLocation selectedLocation = new TblLocation();

                selectedLocation     = _locationService.GetLocationbyId(Convert.ToInt32(cmbLocation.SelectedValue));
                txtLocationName.Text = selectedLocation.LocationName.Trim();
            }
            else
            {
                txtLocationName.Clear();
            }
        }
Ejemplo n.º 8
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                TblLocation tblLocation = new TblLocation();

                tblLocation.LocationName = txtLocationName.Text.Trim();
                _locationService.SaveLocation(tblLocation);

                MessageBox.Show("Location Successfully Saved");
            }
            catch (Exception a)
            {
            }
        }
Ejemplo n.º 9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                TblLocation tblLocation = new TblLocation();

                tblLocation.LocationName = txtLocationName.Text.Trim();
                tblLocation.LocationId   = Convert.ToInt32(cmbLocation.SelectedValue);
                _locationService.UpdateLocation(tblLocation);

                MessageBox.Show("Location Successfuly Updated");
            }
            catch (Exception a)
            {
                throw a;
            }
        }
        public TblLocation InsertTblLocationToDataBase(TblLocation nLocation)
        {
            try
            {
                if (nLocation != null)
                {
                    nLocation.CreateDate = this.DateOfServer;
                    nLocation.Creator    = nLocation.Creator ?? "someone";

                    this.Context.TblLocation.Add(nLocation);
                    return(this.Context.SaveChanges() > 0 ? this.GetTblLocationWithKey(nLocation.LocationId) : null);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Has error " + ex.ToString());
            }
            return(null);
        }
        public TblLocation UpdateTblLocationToDataBase(int LocationID, TblLocation uLocation)
        {
            try
            {
                var dbLocation = this.Context.TblLocation.Find(LocationID);
                if (dbLocation != null)
                {
                    uLocation.CreateDate = dbLocation.CreateDate;
                    uLocation.ModifyDate = this.DateOfServer;
                    uLocation.Modifyer   = uLocation.Modifyer ?? "someone";

                    this.Context.Entry(dbLocation).CurrentValues.SetValues(uLocation);
                    return(this.Context.SaveChanges() > 0 ? this.GetTblLocationWithKey(LocationID) : null);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Has error " + ex.ToString());
            }
            return(null);
        }
        public TblContact InsertTblContactOnlyLocationToDataBase(TblLocation nContactOnlyLocation)
        {
            try
            {
                if (nContactOnlyLocation != null)
                {
                    if (this.GetTblLocations.Where(x => x.LocationName.Trim().ToLower() == nContactOnlyLocation.LocationName.Trim().ToLower()).Any())
                    {
                        return(null);
                    }

                    string LocationCode = "OZ" + ((this.GetTblLocations.Where(x => x.LocationCode.StartsWith("OZ"))?.Count() ?? 1) + 1).ToString("0");

                    var nContact = new TblContact()
                    {
                        ContactName        = "",
                        ContactPhone       = "",
                        CreateDate         = this.DateOfServer,
                        Creator            = nContactOnlyLocation.Creator ?? "someone",
                        LocationNavigation = new TblLocation()
                        {
                            CreateDate      = this.DateOfServer,
                            Creator         = nContactOnlyLocation.Creator ?? "someone",
                            LocationAddress = nContactOnlyLocation.LocationAddress,
                            LocationCode    = LocationCode,
                            LocationName    = nContactOnlyLocation.LocationName
                        }
                    };

                    this.Context.TblContact.Add(nContact);
                    return(this.Context.SaveChanges() > 0 ? this.GetTblContactWithKey(nContact.ContactId) : null);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Has error " + ex.ToString());
            }
            return(null);
        }
Ejemplo n.º 13
0
        public void ClearForm()
        {
            btnAdd.Show();
            btnSave.Hide();

            //load combobox
            lstLocation = _locationService.GetLocations();
            TblLocation item = new TblLocation();

            item.LocationName = "---Select Location--";
            item.LocationId   = 0;

            lstLocation.Add(item);
            cmbLocation.DataSource = lstLocation;


            cmbLocation.ValueMember        = "LocationId";
            cmbLocation.DisplayMember      = "LocationName";
            cmbLocation.DropDownStyle      = System.Windows.Forms.ComboBoxStyle.DropDown;
            cmbLocation.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            cmbLocation.AutoCompleteSource = AutoCompleteSource.ListItems;
            cmbLocation.SelectedValue      = 0;
            //till here
        }
Ejemplo n.º 14
0
 public int InsertTblLocation(TblLocation lc)
 {
     return(ld.InsertLocation(lc));
 }
Ejemplo n.º 15
0
 public IActionResult Put(string id, [FromBody] TblLocation uLocation)
 {
     return(new JsonResult(this.repository.UpdateAsync(uLocation, id).Result, this.DefaultJsonSettings));
 }
Ejemplo n.º 16
0
 public IActionResult Post([FromBody] TblLocation nLocation)
 {
     return(new JsonResult(this.repository.AddAsync(nLocation).Result, this.DefaultJsonSettings));
 }
Ejemplo n.º 17
0
 public void SaveLocation(TblLocation location)
 {
     dbContext.TblLocation.Add(location);
     dbContext.SaveChanges();
 }
Ejemplo n.º 18
0
        public TblLocation GetLocationbyId(int locationId)
        {
            TblLocation location = dbContext.TblLocation.FirstOrDefault(p => p.isDeleted == false && p.LocationId == locationId);

            return(location);
        }
Ejemplo n.º 19
0
 public int UpdateTblLocation(TblLocation lc)
 {
     return(ld.Updatelocation(lc));
 }