public static bool InsertOrUpdate(Conversations con) { try { if (db.Conversations.Any(v => v.ConverstationId == con.ConverstationId)) { db.Entry(con).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return true; } else { con.Status = 0; db.Conversations.Add(con); db.SaveChanges(); return true; } } catch (Exception ex) { return false; throw; } }
public static bool Insert(Offers offer) { try { Conversations con = new Conversations(); con.MemberId = offer.MemberId; con.OfferId = offer.OfferId; con.PhotographerId = offer.PhotographerId; con.RequestId = offer.RequestId; con.Status = 0; con.Title = offer.Title; offer.Conversations.Add(con); offer.Status = 0; offer.CreateTime = DateTime.Now; db.Offers.Add(offer); db.SaveChanges(); return true; } catch (Exception ex) { return false; throw; } }