public async Task <NotificationResult> UpdateAsync(ShoplistIngredientInfo item)
        {
            var result = new NotificationResult();

            try
            {
                _context.Attach(item);
                _context.Entry(item).State = EntityState.Modified;
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                result.AddError(ex);
            }

            return(result);
        }
        public async Task <NotificationResult> InsertAsync(ShoplistIngredientInfo item)
        {
            var result = new NotificationResult();

            try
            {
                await _context.AddAsync(item);

                item.SetId(_context.SaveChanges());
            }
            catch (Exception ex)
            {
                result.AddError(ex);
            }

            return(result);
        }
Exemple #3
0
        public virtual async Task <NotificationResult> InsertAsync(InsertShoplistIngredientCommand command)
        {
            var result = new NotificationResult();
            var item   = new ShoplistIngredientInfo(command);

            result.Add(item.GetNotificationResult());
            if (!result.IsValid)
            {
                return(result);
            }
            result.Add(await _shoplistIngredientRepository.InsertAsync(item));
            if (result.IsValid)
            {
                result.Data = item.Id;
                result.AddMessage(Shared.Domain.Resources.Handler.InsertSuccess_Message);
            }
            else
            {
                result.AddErrorOnTop(Shared.Domain.Resources.Handler.InsertError_Message);
            }
            return(result);
        }
Exemple #4
0
 public static void InsertOrUpdateScopeValidate(this ShoplistIngredientInfo item)
 {
     new NotificationContract <ShoplistIngredientInfo>(item);
 }