public int SubmitGroomMen(int UserID, GroomAndManBO groomBO) { GroomAndMan groom = new GroomAndMan(); ObjectMapper.Map(groomBO, groom); return(WeddingRepository.SubmitGroomMen(UserID, groom)); }
public int SubmitGroomMen(int UserID, GroomAndMan groom) { if (groom.DateofBirth.Value.Year == 1) { groom.DateofBirth = null; } using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted })) { if (groom.GroomAndMenID == 0) { groom.CreatedDate = DateTime.Now; AccuitAdminDbContext.GroomAndMen.Add(groom); AccuitAdminDbContext.SaveChanges(); scope.Complete(); } else { GroomAndMan groomMen = AccuitAdminDbContext.GroomAndMen.Where(x => x.GroomAndMenID == groom.GroomAndMenID).First(); groomMen.ModifiedDate = DateTime.Now; groomMen.AboutMen = groom.AboutMen; groomMen.DateofBirth = groom.DateofBirth; groomMen.FirstName = groom.FirstName; groomMen.Imageurl = groom.Imageurl; groomMen.IsGroom = groom.IsGroom; groomMen.LastName = groom.LastName; groomMen.RelationWithGroom = groom.RelationWithGroom; groomMen.fbUrl = groom.fbUrl; groomMen.googleUrl = groom.googleUrl; groomMen.instagramUrl = groom.instagramUrl; groomMen.IsDeleted = groom.IsDeleted; AccuitAdminDbContext.Entry <GroomAndMan>(groomMen).State = System.Data.Entity.EntityState.Modified; AccuitAdminDbContext.SaveChanges(); scope.Complete(); } } return(groom.GroomAndMenID); }