public LawsuitViewModel CreateLawsuit(LawsuitViewModel model, string[] lawyers) { DateTime dt; DateTime.TryParse(model.dateTimeOfEvent.ToString(), out dt); List <User> laws = context.Users.ToList(); List <User> selectedLawyers = new List <User>(); Lawsuit lawsuit = new Lawsuit { dateTimeOfEvent = dt, location = locationRepository.get(model.location), judge = contactRepository.get(model.judge), courtType = model.courtType, processId = model.processId, courtroomNumber = model.courtroomNumber, prosecutor = contactRepository.get(model.prosecutor), defendant = contactRepository.get(model.defendant), note = model.note, typeOfProcess = typeOfRepository.get(model.typeOfProcess), }; lawsuitRepository.add(lawsuit); foreach (string lawyerId in lawyers) { context.LawsuitLawyers.Add(new LawsuitLawyer { lawsuitId = lawsuit.id, userId = lawyerId }); context.SaveChanges(); } if (lawyers.Contains(userManager.GetUserId(HttpContext.User))) { model.id = lawsuit.id; model.locations = this.locationRepository.getAll("name_desc", ""); model.contacts = this.contactRepository.getAll("name_desc", ""); model.processes = this.typeOfRepository.getAll("name_desc", ""); model.courtTypes = Enum.GetValues(typeof(TipSuda)).Cast <TipSuda>() .ToDictionary(e => (int)e, e => e.ToString()); return(model); } return(null); }
public void add(Location location) { context.Locations.Add(location); context.SaveChanges(); }
public void add(Contact contact) { context.Contacts.Add(contact); context.SaveChanges(); }
public void add(Lawsuit lawsuit) { context.Lawsuits.Add(lawsuit); context.SaveChanges(); }
public void add(Company company) { context.Companies.Add(company); context.SaveChanges(); }
public void add(TypeOfProcess typeOfProcess) { context.TypeOfProcesses.Add(typeOfProcess); context.SaveChanges(); }