public ActionResult SaveDetails(FormCollection collection) { BookDetails book = new BookDetails(); //book.BookId = b.BookId; book.Name = collection["Name"]; book.Contact = Convert.ToInt64(collection["Contact"]); entity.BookDetails.Add(book); entity.SaveChanges(); HireDetails hire = new HireDetails(); hire.StartDate = Convert.ToDateTime(collection["StartDate"]).Date; hire.EndDate = Convert.ToDateTime(collection["EndDate"]).Date; hire.Type = collection["Type"]; hire.Capacity = Convert.ToInt32(collection["Capacity"]); hire.Source = Convert.ToInt32(collection["Source"]); hire.Destination = Convert.ToInt32(collection["Destination"]); hire.Return = collection["Return"]; hire.BookId = book.BookId; entity.BookDetails.Add(book); entity.HireDetails.Add(hire); entity.SaveChanges(); return(RedirectToAction("Success", "Home")); }
/// <summary> /// Returns true if EmploymentDetails instances are equal /// </summary> /// <param name="other">Instance of EmploymentDetails to be compared</param> /// <returns>Boolean</returns> public bool Equals(EmploymentDetails other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( EmploymentStatus == other.EmploymentStatus || EmploymentStatus != null && EmploymentStatus.Equals(other.EmploymentStatus) ) && ( EmployeeType == other.EmployeeType || EmployeeType != null && EmployeeType.Equals(other.EmployeeType) ) && ( HireDetails == other.HireDetails || HireDetails != null && HireDetails.Equals(other.HireDetails) ) && ( DateJoinedNHS == other.DateJoinedNHS || DateJoinedNHS != null && DateJoinedNHS.Equals(other.DateJoinedNHS) ) && ( AlAccrualPlan == other.AlAccrualPlan || AlAccrualPlan != null && AlAccrualPlan.Equals(other.AlAccrualPlan) ) && ( PrevEmployer == other.PrevEmployer || PrevEmployer != null && PrevEmployer.Equals(other.PrevEmployer) ) && ( Agencies == other.Agencies || Agencies != null && Agencies.Equals(other.Agencies) )); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (EmploymentStatus != null) { hashCode = hashCode * 59 + EmploymentStatus.GetHashCode(); } if (EmployeeType != null) { hashCode = hashCode * 59 + EmployeeType.GetHashCode(); } if (HireDetails != null) { hashCode = hashCode * 59 + HireDetails.GetHashCode(); } if (DateJoinedNHS != null) { hashCode = hashCode * 59 + DateJoinedNHS.GetHashCode(); } if (AlAccrualPlan != null) { hashCode = hashCode * 59 + AlAccrualPlan.GetHashCode(); } if (PrevEmployer != null) { hashCode = hashCode * 59 + PrevEmployer.GetHashCode(); } if (Agencies != null) { hashCode = hashCode * 59 + Agencies.GetHashCode(); } return(hashCode); } }