public async Task <Result <UntaggedUPC> > UpdateUntaggedUPC(UntaggedUPC upc) { _dbContext.UntaggedUPC.Update(upc); await _dbContext.SaveChangesAsync(); return(Result.Ok(upc)); }
public async Task <Result <TaggedUPC> > Insert(TaggedUPC taggedUPC, UPCHistory upcHistory) { try { _dbContext.Add <TaggedUPC>(taggedUPC); //_dbContext.Add<UPCHistory>(upcHistory); var result = await _dbContext.SaveChangesAsync(); if (result <= 0) { return(Result.Fail <TaggedUPC>(Constants.No_Rows_Added)); } return(Result.Ok(taggedUPC)); } catch (Exception ex) { throw ex; } }
public async Task <Result <User> > CreateUser(User user) { try { var userObj = await _dbContext.User.FirstOrDefaultAsync(s => s.Email == user.Email); if (userObj != null) { return(Result.Fail <User>(Constants.User_Already_Exist)); } _dbContext.Add <User>(user); var result = await _dbContext.SaveChangesAsync(); if (result <= 0) { return(Result.Fail <User>(Constants.User_Not_Created)); } return(Result.Ok(user)); } catch (Exception ex) { throw ex; } }