public void Put(int id, [FromBody] PreviousOwner previousOwner) { previousOwner.PreviousOwnerId = id; _db.Entry(previousOwner).State = EntityState.Modified; _db.SaveChanges(); }
public PreviousOwner CreatePreviousOwner(PreviousOwner preOwner) { preOwner.Id = FakeDB.PreOwnerId++; FakeDB.PreOwners.Add(preOwner); return(preOwner); }
public PreviousOwner UpdatePreviousOwner(PreviousOwner preOwnerChanges) { _ctx.Attach(preOwnerChanges).State = EntityState.Modified; _ctx.Entry(preOwnerChanges).Reference(p => p.FormerPets).IsModified = true; _ctx.SaveChanges(); return(preOwnerChanges); }
public ActionResult <PreviousOwner> Put(int id, [FromBody] PreviousOwner preOwner) { if (id < 1 || id != preOwner.Id) { return(BadRequest("Parameter Id and customer ID must be the same")); } return(Ok(_previousOwnerService.UpdatePreviousOwner(preOwner))); }
public PreviousOwner CreatePreviousOwner(PreviousOwner preOwner) { if (preOwner.FormerPets == null) { throw new InvalidDataException("To create previous owner you need a pet"); } return(_previousOwnerRepository.CreatePreviousOwner(preOwner)); }
public PreviousOwner UpdatePreviousOwner(PreviousOwner preOwnerChanges) { var newPreOwner = GetPreviousOwner(preOwnerChanges.Id); if (newPreOwner != null) { newPreOwner.Name = preOwnerChanges.Name; newPreOwner.PhoneNumber = preOwnerChanges.PhoneNumber; return(newPreOwner); } return(null); }
public override int GetHashCode() { int hash = 1; if (Blockchain.Length != 0) { hash ^= Blockchain.GetHashCode(); } if (SrcAddress.Length != 0) { hash ^= SrcAddress.GetHashCode(); } if (DstAddress.Length != 0) { hash ^= DstAddress.GetHashCode(); } if (Amount.Length != 0) { hash ^= Amount.GetHashCode(); } if (Expiration != 0UL) { hash ^= Expiration.GetHashCode(); } if (Block.Length != 0) { hash ^= Block.GetHashCode(); } if (Deal.Length != 0) { hash ^= Deal.GetHashCode(); } if (PreviousOwner.Length != 0) { hash ^= PreviousOwner.GetHashCode(); } if (Transfer.Length != 0) { hash ^= Transfer.GetHashCode(); } if (Sighash.Length != 0) { hash ^= Sighash.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public static void InitData() { var preOwner1 = new PreviousOwner() { Id = PreOwnerId++, Name = "Bob", PhoneNumber = 54263598 }; PreOwners.Add(preOwner1); var pet1 = new Pet() { Id = PetId++, AnimalCategory = "Dog", Color = "Blå", Name = "IkkeBob", Price = 500, Sold = true, BirthDate = new DateTime(1999, 05, 26), SoldDate = new DateTime(2003, 02, 07), PreviousOwner = preOwner1 }; Pets.Add(pet1); var preOwner2 = new PreviousOwner() { Id = PreOwnerId++, Name = "Jamal", PhoneNumber = 65329647 }; PreOwners.Add(preOwner2); var pet2 = new Pet() { Id = PetId++, AnimalCategory = "Cat", Color = "Black", Name = "Flamingo", Price = 596, Sold = false, BirthDate = new DateTime(2002, 11, 09), PreviousOwner = preOwner2 }; Pets.Add(pet2); }
internal string[] GetNotificationSubscribers() { var subs = new List <string>(); if (!string.IsNullOrEmpty(PreviousOwner) && !PreviousOwner.Equals(Owner, StringComparison.InvariantCultureIgnoreCase)) { subs.Add(PreviousOwner); } if (!string.IsNullOrEmpty(PreviousAssignedUser) && !PreviousAssignedUser.Equals(AssignedTo, StringComparison.InvariantCultureIgnoreCase)) { subs.Add(PreviousAssignedUser); } if (!string.IsNullOrEmpty(Owner)) { subs.Add(Owner); } if (!string.IsNullOrEmpty(AssignedTo)) { subs.Add(AssignedTo); } return(subs.ToArray()); }
public void Post([FromBody] PreviousOwner preOwner) { _previousOwnerService.CreatePreviousOwner(preOwner); }
public PreviousOwner CreatePreviousOwner(PreviousOwner preOwner) { _ctx.Attach(preOwner).State = EntityState.Added; _ctx.SaveChanges(); return(preOwner); }
public override string ToString() { return($"ID = {ID.ToString()}, Name = {Name.ToString()}, Type = {Type.ToString()}, BirthDate = {BirthDate.ToString()}, SoldDate = {SoldDate.ToString()}, Color = {Color.ToString()}, PreviousOwner = {PreviousOwner.ToString()}, Price = {Price.ToString()},\n"); }
public void Post([FromBody] PreviousOwner previousOwner) { _db.PreviousOwners.Add(previousOwner); _db.SaveChanges(); }
public PreviousOwner UpdatePreviousOwner(PreviousOwner preOwnerChanges) { return(_previousOwnerRepository.UpdatePreviousOwner(preOwnerChanges)); }