public RegisteredRequest CloseRequest(UpdateRequest updateRequest) { using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext()) { using (var transaction = helpDeskDataContext.Database.BeginTransaction()) { var request = updateRequest.ToEntityClose(); helpDeskDataContext.Requests.Attach(request); helpDeskDataContext.Entry(request).Property(x => x.State).IsModified = true; helpDeskDataContext.Entry(request).Property(x => x.LastUpdateUserId).IsModified = true; helpDeskDataContext.SaveChanges(); transaction.Commit(); return(request.ToDTO()); } } }
public RegisteredEvent CreateReview(CreateEvent newRegistry) { using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext()) { using (var transaction = helpDeskDataContext.Database.BeginTransaction()) { try { var eEvent = newRegistry.ToEntityReview(); helpDeskDataContext.Events.Add(eEvent); helpDeskDataContext.SaveChanges(); var eRequest = helpDeskDataContext.Requests.Where(x => x.Id == eEvent.RequestId).First(); eRequest.State = 3; helpDeskDataContext.Requests.Attach(eRequest); helpDeskDataContext.Entry(eRequest).Property(x => x.State).IsModified = true; helpDeskDataContext.SaveChanges(); transaction.Commit(); return(eEvent.ToDTO()); } catch (Exception) { transaction.Rollback(); return(new RegisteredEvent()); } } } }
public RegisteredModule Update(UpdateModule updateRegistry) { using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext()) { var module = updateRegistry.ToEntity(); helpDeskDataContext.Modules.Attach(module); helpDeskDataContext.Entry(module).Property(x => x.Name).IsModified = true; helpDeskDataContext.SaveChanges(); return(module.ToDTO()); } }