Ejemplo n.º 1
0
        public virtual IActionResult DeleteManyConfirmed(long[] ids)
        {
            foreach (var id in ids)
            {
                if (_service.CanDelete(id))
                {
                    _service.Delete(id);
                }
            }

            return(RedirectToAction(nameof(Index)));
        }
 /// <summary>
 /// Deletes the entity from the persistence infrastructure layer
 /// </summary>
 /// <param name="id">Id of the entity to be deleted</param>
 /// <returns>Id of the deleted item, 0 otherwise</returns>
 public virtual int Delete(int id)
 {
     try
     {
         // delete the entity matching from id in the database
         Tuple <bool, TModelEntity> result = _crudService.Delete(new object[] { id });
         return(result.Item1 ? id : 0);
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, Literals.p_ErrorDeletingDtoOfTypeX.ParseParameter(typeof(TDomainEntity).Name));
         throw;
     }
 }
Ejemplo n.º 3
0
 public async Task <bool> DeleteRole(Guid id)
 {
     return(await Task.Run(() =>
     {
         return _rolesService.Delete(id);
     }));
 }
Ejemplo n.º 4
0
        private async Task <Notification> EditInvoice(Invoice invoice, IdentityUser user)
        {
            try
            {
                _unitOfWork.BeginTransaction();

                var record = await _invoiceCrudService.GetAsync(invoice.Id);

                record.IsTicket     = invoice.IsTicket;
                record.ReferenceNo  = invoice.ReferenceNo;
                record.Dr           = invoice.Dr;
                record.FileCodeNo   = invoice.FileCodeNo;
                record.Address      = invoice.Address;
                record.ClientName   = invoice.ClientName;
                record.Currency     = invoice.Currency;
                record.PAX          = invoice.PAX;
                record.Guide        = invoice.Guide;
                record.Vehicle      = invoice.Vehicle;
                record.TotalDue     = invoice.TotalDue;
                record.Discount     = invoice.Discount;
                record.NetAmount    = invoice.NetAmount;
                record.ModifiedBy   = user.Id;
                record.ModifiedDate = DateTime.Now;

                var invoiceDetails = _invoiceDetailCrudService.GetAll(p => p.InvoiceId == invoice.Id);

                foreach (InvoiceDetail invoiceDetail in invoiceDetails)
                {
                    if (!invoice.InvoiceDetails.Any(x => x.Id == invoiceDetail.Id))
                    {
                        _invoiceDetailCrudService.Delete(invoiceDetail);
                    }
                }

                foreach (InvoiceDetail invoiceDetail in invoice.InvoiceDetails)
                {
                    if (!invoiceDetails.Contains(invoiceDetail))
                    {
                        await _invoiceDetailCrudService.InsertAsync(new InvoiceDetail
                        {
                            InvoiceId   = invoice.Id,
                            Particulars = invoiceDetail.Particulars,
                            Amount      = invoiceDetail.Amount,
                            CreatedBy   = user.Id
                        });
                    }
                }

                _invoiceCrudService.Update(record);
                _unitOfWork.Commit();

                return(new Notification("success", "Invoice updated successfully."));
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                _unitOfWork.Rollback();
                return(new Notification("error", "Invoice update failed."));
            }
        }
Ejemplo n.º 5
0
        public HttpResponseMessage DeleteItem(int id)
        {
            var item = _itemService.Get(id);

            return(CreateResponseBuilder().WithCondition(() => UserIsAdmin)
                   .WithMethod(() => _itemService.Delete(item)));
        }
Ejemplo n.º 6
0
 public async Task <bool> DeleteAdmin(Guid id)
 {
     return(await Task.Run(() =>
     {
         return _adminsService.Delete(id);
     }));
 }
Ejemplo n.º 7
0
 public async Task <bool> DeleteClient(Guid id)
 {
     return(await Task.Run(() =>
     {
         return _clientsService.Delete(id);
     }));
 }
Ejemplo n.º 8
0
 public async Task <bool> DeleteElementGenericChore(Guid id)
 {
     return(await Task.Run(() =>
     {
         return _elementGenericChoresService.Delete(id);
     }));
 }
 public async Task <bool> DeleteBook(Guid id)
 {
     return(await Task.Run(() =>
     {
         return _orderitemsService.Delete(id);
     }));
 }
Ejemplo n.º 10
0
 public async Task <bool> DeleteInstallationUser(Guid id)
 {
     return(await Task.Run(() =>
     {
         return _installationUsersService.Delete(id);
     }));
 }
Ejemplo n.º 11
0
 public async Task <bool> DeleteGenericChoreFormatLabel(Guid id)
 {
     return(await Task.Run(() =>
     {
         return _genericChoreFormatLabelsService.Delete(id);
     }));
 }
Ejemplo n.º 12
0
        public virtual ActionResult Delete(dynamic id)
        {
            var dto = _service.GetByID(id);

            _service.Delete(dto);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 13
0
        public CrudModule(IDataContext dataContext, IValidator widgetValidator, IEventHub eventHub, ICrudService crudService, ISettings settings)
        {
            Post($"/api/v1/{settings.EntityName}/", async parameters =>
            {
                var rtn = await crudService.Add(dataContext, MakeModel(), widgetValidator);
                if (rtn.Success)
                {
                    await eventHub.OnCreated(rtn.Result);
                }
                return(rtn);
            });

            Put($"/api/v1/{settings.EntityName}/", async parameters =>
            {
                var rtn = await crudService.Update(dataContext, MakeModel(), widgetValidator);
                if (rtn.Success)
                {
                    await eventHub.OnUpdated(rtn.Result);
                }
                return(rtn);
            });

            Delete($"/api/v1/{settings.EntityName}/", async parameters =>
            {
                var rtn = await crudService.Delete(dataContext, MakeModel(), widgetValidator);
                if (rtn.Success)
                {
                    await eventHub.OnDeleted(rtn.Result);
                }
                return(rtn);
            });
        }
Ejemplo n.º 14
0
 public async Task <bool> DeleteChoreType(Guid id)
 {
     return(await Task.Run(() =>
     {
         return _choreTypesService.Delete(id);
     }));
 }
Ejemplo n.º 15
0
        public ActionResult Delete(Guid id)
        {
            try
            {
                _service.Delete(id);
                return(Ok());
            }

            catch (InvalidTransactionException exception)
            {
                ModelState.AddModelError("ErrorMessage", exception.Message);
                return(BadRequest(ModelState));
            }

            catch (NotFoundException)
            {
                ModelState.AddModelError("ErrorMessage", Messages.DangerRecordNotFound);
                return(NotFound(ModelState));
            }

            catch (Exception)
            {
                ModelState.AddModelError("ErrorMessage", Messages.DangerRecordNotFound);
                return(BadRequest(ModelState));
            }
        }
Ejemplo n.º 16
0
        public async Task <IActionResult> OnPostDeleteAsync(int id)
        {
            _seatCategoryService.Delete(id).Wait();
            SeatCategorylist = await _seatCategoryService.GetAll();

            return(Page());
        }
Ejemplo n.º 17
0
 public async Task <bool> DeleteCategory(Guid id)
 {
     return(await Task.Run(() =>
     {
         return _categoriesService.Delete(id);
     }));
 }
 public async Task <bool> DeleteBook(Guid id)
 {
     return(await Task.Run(() =>
     {
         return _employeesService.Delete(id);
     }));
 }
Ejemplo n.º 19
0
 public async Task <bool> DeleteFloor(Guid id)
 {
     return(await Task.Run(() =>
     {
         return _floorsService.Delete(id);
     }));
 }
Ejemplo n.º 20
0
 public async Task <bool> DeleteGenericElement(Guid id)
 {
     return(await Task.Run(() =>
     {
         return _genericElementsService.Delete(id);
     }));
 }
        public async Task <IActionResult> OnPostDeleteAsync(int id)
        {
            ThemeService.Delete(id).Wait();
            Themes = await ThemeService.GetAll();

            return(Page());
        }
Ejemplo n.º 22
0
        public virtual async Task <IActionResult> Delete(string key)
        {
            var model = await _service[key];

            _service.Delete(model);
            return(Result.Factory());
        }
Ejemplo n.º 23
0
 public async Task <bool> DeleteFormat(Guid id)
 {
     return(await Task.Run(() =>
     {
         return _formatValuesService.Delete(id);
     }));
 }
Ejemplo n.º 24
0
 public async Task <bool> DeleteBuilding(Guid id)
 {
     return(await Task.Run(() =>
     {
         return _buildingsService.Delete(id);
     }));
 }
Ejemplo n.º 25
0
        public async Task <IActionResult> OnPostDeleteAsync(int id)
        {
            EnrollmentSevice.Delete(id).Wait();

            Enrollments = await EnrollmentSevice.GetAll();

            return(Page());
        }
        public async Task <IActionResult> OnPostDeleteAsync(int htnr)
        {
            SpeakerService.Delete(htnr).Wait();

            Speakers = await SpeakerService.GetAll();

            return(Page());
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Supprime une permission
        /// </summary>
        /// <param name="permission"></param>
        public virtual void DeletePermissionRecord(PermissionRecord permission)
        {
            if (permission == null)
            {
                throw new ArgumentNullException(nameof(permission));
            }

            _permissionRecordRepository.Delete(permission);
        }
        public IActionResult Delete(FileEntry model)
        {
            var fileEntry = _fileEntryService.GetById(model.Id);

            _fileEntryService.Delete(fileEntry);
            _fileManager.Delete(fileEntry);

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 29
0
        public void DeleteShouldDeleteEntity()
        {
            var input = new DeleteConfirmInput {
                Id = 123
            };

            countryController.Delete(input).ShouldBeJson();
            A.CallTo(() => countryCrudSrv.Delete(input.Id)).MustHaveHappened();
        }
Ejemplo n.º 30
0
 public IActionResult DeleteAssignee(long id)
 {
     if (service.IsInDataBase(id))
     {
         service.Delete(id);
         return(Ok());
     }
     return(StatusCode(404, new ErrorMessage("No such todo")));
 }