[Route("{Key}")] //<--key == petId public ActionResult PutEdit(int key, [FromBody] Grooming gro) { pethouseContext db = new pethouseContext(); try { Grooming groDb = db.Grooming.Find(key); if (gro != null) { groDb.Groomname = gro.Groomname; groDb.GroomDate = gro.GroomDate; groDb.GroomExpDate = gro.GroomExpDate; groDb.Comments = gro.Comments; db.SaveChanges(); return(Ok(groDb.GroomId)); } else { return(NotFound("Not found")); } } catch (Exception) { return(BadRequest("Error")); } finally { db.Dispose(); } }
public async Task <IActionResult> Edit(int id, [Bind("ID,Overall,Shedding,Drool,Easiness")] Grooming grooming) { if (id != grooming.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(grooming); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GroomingExists(grooming.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(grooming)); }
public decimal getPriceFromGroomingSize(Grooming grooming, Petsize size) { string condition = string.Format(" grooming_id = {0} AND petsize_id = {1}", grooming.Id, (int)size); object price = readScalar("price",condition); if(price != null) return (decimal)price; else return 0; }
public List<Grooming> getListOfGrooming() { List<Grooming> groomings = new List<Grooming>(); List<Entity> entities = getListOfEntity("SELECT grooming_id, grooming_name FROM grooming_tbl"); foreach (Entity entity in entities) { Grooming grooming = new Grooming(entity); groomings.Add(grooming); } return groomings; }
public async Task <IActionResult> Create([Bind("ID,Overall,Shedding,Drool,Easiness")] Grooming grooming) { if (ModelState.IsValid) { _context.Add(grooming); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(grooming)); }
public Appearance() { description = new List <string>(); theAge = new Age(); theBeauty = new Beauty(); theDexterity = new Dexterity(); theGrooming = new Grooming(); theHeight = new Height(); theStrength = new Strength(); theWeight = new Weight(); }
public bool updateGrooming(Grooming oldGrooming, Grooming newGrooming) { if (oldGrooming.Name == newGrooming.Name) return false; string condition = string.Format("grooming_name = '{0}'", oldGrooming.Name); string grooming_name = string.Empty; grooming_name = string.Format("grooming_name = '{0}'", newGrooming.Name); return update( updateSet(condition, grooming_name) ); }
[HttpPost] //<-- filtteri, joka sallii vain POST-metodit //[Route("")]// <-- Routen placeholder public ActionResult PostCreateNew([FromBody] Grooming grooming) { pethouseContext db = new pethouseContext(); //Tietokanta yhteytden muodostus try { db.Grooming.Add(grooming); db.SaveChanges(); } catch (Exception ex) { string virhe = ex.GetType().Name.ToString() + ": " + ex.Message.ToString(); return(BadRequest("Request failed with error:\n" + virhe)); } db.Dispose(); //Tietokannan vapautus return(Ok(grooming.PetId)); //Palauttaa vastaluodun uuden objektin avainarvon }
//Get the latest grooming operation public Grooming GetTheLatestGrooming(int key) { pethouseContext db = new pethouseContext(); Grooming grooming = (from p in db.Grooming where p.PetId == key orderby p.GroomDate descending select p).FirstOrDefault(); if (grooming != null) { return(grooming); } else { return(null); } }
void mappedServiceToFields(Service service) { if (service is GPP) { origGPP = service as GPP; origGrooming = dbController.groomingMapper.getGroomingFromId(origGPP.grooming_id); txtName.Text = origGrooming.Name; txtPrice.Text = origGPP.price.ToString(); cbSize.Text = origGPP.petsize.ToString(); } else if (service is Medical) { origMedical = service as Medical; txtName.Text = origMedical.Name; rbMedical.Checked = true; txtPrice.Clear(); } }
public ActionResult DeleteGrooming(int?key) { if (key is null) { throw new ArgumentNullException(nameof(key)); } pethouseContext db = new pethouseContext(); try { Grooming grooming = db.Grooming.Find(key); db.Remove(grooming); db.SaveChanges(); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok()); }
public ActionResult DeleteAllGroomings(int?key) { if (key is null) { throw new ArgumentNullException(nameof(key)); } pethouseContext db = new pethouseContext(); try { Grooming groomingRow = db.Grooming.Where(s => s.PetId == key).FirstOrDefault(); db.Remove(groomingRow); db.SaveChanges(); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok()); }
public GPP getGPPFromGroomingSize(Grooming grooming, Petsize size) { string condition = string.Format("grooming_id = {0} AND petsize_id = {1}", grooming.Id, (int)size); Entity entity = getEntityWhere(condition); return new GPP(entity); }
public string createGroomingQuery(Grooming grooming) { return insertValues("null", grooming.Name); }
public bool insertGrooming(Grooming grooming) { return create(insertValues("null", grooming.Name)); }
void updateGrooming() { grooming = new Grooming(){ Name = txtName.Text, }; dbController.updateGrooming(origGrooming, grooming); updateGPP(grooming); }
void insertGrooming() { string name = string.Empty; decimal price = 0; name = txtName.Text; price = Decimal.Parse(txtPrice.Text); Petsize size = dbController.petsizeMapper.getPetsizeFromName(cbSize.Text); if (!checkIfGroomingAlreadyExists(name)){ grooming = new Grooming(){ Name = name }; if (dbController.insertGrooming(grooming)){ grooming.Id = dbController.getGroomingIDFromName(grooming.Name); dbController.insertGPP(grooming, size, price); } } else{ dbController.insertGPP(grooming, size, price); } }
public bool updateGrooming(Grooming oldGrooming, Grooming newGrooming) { if (groomingMapper.updateGrooming(oldGrooming, newGrooming)){ OnUpdateEntity(new EntityArgs(newGrooming)); return true; } return false; }
public string createGPPQuery(Grooming grooming, Petsize size, decimal price) { return insertValues("null", grooming.Id, (int)size, price); }
public bool insertGPP(Grooming grooming, Petsize size, decimal price){ return create(insertValues("null", grooming.Id, (int)size, price)); }
public decimal getPriceFromGroomingSize(Grooming grooming, Petsize size) { return gppMapper.getPriceFromGroomingSize(grooming, size); }
public bool insertGPP(Grooming grooming, Petsize size, decimal price) { if (gppMapper.insertGPP(grooming, size, price)) { OnInsertEntity(new EntityArgs(grooming)); return true; } return false; }
public bool insertGrooming(Grooming grooming) { if (groomingMapper.insertGrooming(grooming)) { OnInsertEntity(new EntityArgs(grooming)); return true; } return false; }
public bool insertGroomingAndGPP(Grooming grooming, Petsize size, decimal price) { string insertGrooming = groomingMapper.createGroomingQuery(grooming); string insertGPP = gppMapper.createGPPQuery(grooming, size, price); if (createTransaction(insertGrooming, insertGPP)) { OnInsertEntity(new EntityArgs(grooming)); return true; } return false; }
void updateGPP(Grooming grooming) { GPP gpp = new GPP() { price = decimal.Parse(txtPrice.Text), }; dbController.updateGPP(origGPP, gpp); }
public GPP getGPPFromGroomingSize(Grooming grooming, Petsize size) { return gppMapper.getGPPFromGroomingSize(grooming, size); }