public async Task <bool> Create(StoreRepresent StoreRepresent) { StoreRepresentDAO StoreRepresentDAO = new StoreRepresentDAO(); StoreRepresentDAO.Id = StoreRepresent.Id; StoreRepresentDAO.Name = StoreRepresent.Name; StoreRepresentDAO.DateOfBirth = StoreRepresent.DateOfBirth; StoreRepresentDAO.Phone = StoreRepresent.Phone; StoreRepresentDAO.Email = StoreRepresent.Email; StoreRepresentDAO.PositionId = StoreRepresent.PositionId; StoreRepresentDAO.StoreId = StoreRepresent.StoreId; DataContext.StoreRepresent.Add(StoreRepresentDAO); await DataContext.SaveChangesAsync(); StoreRepresent.Id = StoreRepresentDAO.Id; await SaveReference(StoreRepresent); return(true); }
public async Task <bool> BulkMerge(List <StoreRepresent> StoreRepresents) { List <StoreRepresentDAO> StoreRepresentDAOs = new List <StoreRepresentDAO>(); foreach (StoreRepresent StoreRepresent in StoreRepresents) { StoreRepresentDAO StoreRepresentDAO = new StoreRepresentDAO(); StoreRepresentDAO.Id = StoreRepresent.Id; StoreRepresentDAO.Name = StoreRepresent.Name; StoreRepresentDAO.DateOfBirth = StoreRepresent.DateOfBirth; StoreRepresentDAO.Phone = StoreRepresent.Phone; StoreRepresentDAO.Email = StoreRepresent.Email; StoreRepresentDAO.PositionId = StoreRepresent.PositionId; StoreRepresentDAO.StoreId = StoreRepresent.StoreId; StoreRepresentDAOs.Add(StoreRepresentDAO); } await DataContext.BulkMergeAsync(StoreRepresentDAOs); return(true); }
public async Task <bool> Update(StoreRepresent StoreRepresent) { StoreRepresentDAO StoreRepresentDAO = DataContext.StoreRepresent.Where(x => x.Id == StoreRepresent.Id).FirstOrDefault(); if (StoreRepresentDAO == null) { return(false); } StoreRepresentDAO.Id = StoreRepresent.Id; StoreRepresentDAO.Name = StoreRepresent.Name; StoreRepresentDAO.DateOfBirth = StoreRepresent.DateOfBirth; StoreRepresentDAO.Phone = StoreRepresent.Phone; StoreRepresentDAO.Email = StoreRepresent.Email; StoreRepresentDAO.PositionId = StoreRepresent.PositionId; StoreRepresentDAO.StoreId = StoreRepresent.StoreId; await DataContext.SaveChangesAsync(); await SaveReference(StoreRepresent); return(true); }