示例#1
0
        public async Task <CheckList> UpdateAsync(CheckListUpdate update)
        {
            var result = await access.UpdateAsync(update, userContext.UserId);

            if (result != null)
            {
                await realTimeDataManager.CheckListUpdatedAsync(result);
            }
            return(result);
        }
        public async Task <CheckList> UpdateAsync(CheckListUpdate update, int userId)
        {
            var toUpdate = await context.CheckLists.SingleOrDefaultAsync(c => c.Id == update.Id && c.UserId == userId);

            if (toUpdate != null)
            {
                toUpdate.UpdateFrom(update);
                toUpdate.UpdatedOn = DateTime.Now;
                await context.SaveChangesAsync();
            }
            return(toUpdate);
        }
        public async Task <ActionResult <CheckList> > Update(CheckListUpdate checkList)
        {
            var result = await checkListRepository.UpdateAsync(checkList);

            if (result == null)
            {
                return(this.ValidateAndBadRequest());
            }
            else
            {
                return(result);
            }
        }
        public async Task <CheckList> UpdateAsync(CheckListUpdate checkList)
        {
            var result = await apiClient.Client.PutAsJsonAsync(path, checkList);

            if (result.IsSuccessStatusCode)
            {
                string response = await result.Content.ReadAsStringAsync();

                return(JsonConvert.DeserializeObject <CheckList>(response));
            }
            else
            {
                throw new Exception("error updating data");
            }
        }
 public static void UpdateFrom(this CheckList checkList, CheckListUpdate update)
 {
     checkList.Title = update.Title;
 }