示例#1
0
        public ActionResult Delete(Guid id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                List <StudentModel> studentsList = studentRepository.GetAllStudentsByProgramId(id);
                foreach (StudentModel student in studentsList)
                {
                    List <InvoiceModel> invoices = invoiceRepository.GetAllInvoicesByStudentId(student.StudentId);
                    foreach (InvoiceModel invoice in invoices)
                    {
                        invoiceRepository.Delete(invoice.InvoiceId);
                    }

                    studentRepository.Delete(student.StudentId);
                }

                programRepository.Delete(id);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("Delete"));
            }
        }
示例#2
0
        public ActionResult Delete(Guid id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                List <TeacherModel> teachersList = teacherRepository.GetAllTeachersByCourseId(id);
                foreach (TeacherModel teacher in teachersList)
                {
                    List <StudentModel> studentsList = studentRepository.GetAllStudentsByTeacherId(teacher.TeacherId);
                    foreach (StudentModel student in studentsList)
                    {
                        List <InvoiceModel> invoicesList = invoiceRepository.GetAllInvoicesByStudentId(student.StudentId);
                        foreach (InvoiceModel invoice in invoicesList)
                        {
                            invoiceRepository.Delete(invoice.InvoiceId);
                        }

                        studentRepository.Delete(student.StudentId);
                    }

                    teacherRepository.DeleteTeacher(teacher.TeacherId);
                }

                courseRepository.DeleteCourse(id);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("Delete"));
            }
        }
示例#3
0
        public async Task <IActionResult> Delete(long id)
        {
            var entry = await repo.WithId(id);

            await repo.Delete(entry);

            return(new OkObjectResult(entry));
        }
示例#4
0
        public bool Delete(int id)
        {
            var _invoice = _repository.FindbyId(id);

            if (_invoice == null)
            {
                throw new Exception("Factura no existe");
            }
            return(_repository.Delete(id));
        }
        public IHttpActionResult Delete(int id)
        {
            var user = InvoiceRepo.Get(id);

            if (user == null)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            InvoiceRepo.Delete(id);
            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#6
0
        public async Task <string> DeleteInvoice(int id)
        {
            string status = "";

            if (id > 0)
            {
                await invoiceRepository.Delete(i => i.invoice_id == id);

                status = "deleted";
            }
            return(status);
        }
示例#7
0
 public ActionResult Delete(string id)
 {
     try
     {
         var objectId = ObjectId.Parse(id);
         repository.Delete(objectId);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
示例#8
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         invoiceRepository.Delete(id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View("Delete"));
     }
 }
        public void Delete_Success_ReturnNull()
        {
            // Arrange
            var repository = new InvoiceRepository();
            var input      = repository.Create(GenerateInput());

            // Act
            repository.Delete(input.Id);
            var result = repository.Get(input.Id);

            // Assert
            Assert.IsNull(result);
        }
示例#10
0
        public ActionResult Delete(int id)
        {
            try
            {
                var userId = User.Identity.GetUserId();//dla bezpieczeństwa lepiej zawsze czytać na nowo usera z bazy
                _invoiceRepository.Delete(id, userId);
            }
            catch (Exception exception)
            {
                return(Json(new { Success = false, Message = exception.Message }));
            }

            return(Json(new { Success = true }));
        }
示例#11
0
        public ActionResult DeleteInvoice(int invoiceId)
        {
            try
            {
                var userId = User.Identity.GetUserId();
                _invoiceRepository.Delete(invoiceId, userId);
            }
            catch (Exception exception)
            {
                // TODO: logowanie do pliku niepowodzenie usunięcia faktury
                return(Json(new { Success = false, Message = exception.Message }));
            }

            return(Json(new { Success = true }));
        }
        public async Task <IActionResult> DeleteDepartment(int id)
        {
            int userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);

            ClockItem clockItemFromRepo = await _repo.GetSingleClockItem(userId, id);

            _repo.Delete(clockItemFromRepo);

            if (await _repo.SaveAll())
            {
                return(Ok("Clock item was deleted!"));
            }

            throw new Exception("Deleting clock item failed on save");
        }
        public ActionResult Delete(int id)
        {
            try
            {
                var userId = User.Identity.GetUserId();
                _invoiceRepository.Delete(id, userId);
            }
            catch (Exception exeption)
            {
                return(Json(new { Success = false, Message = exeption.Message }));
            }


            return(Json(new { Success = true }));
        }
示例#14
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            try
            {
                bool result = await _repo.Delete(id);

                if (result)
                {
                    return(RedirectToAction("Index"));
                }
                return(View("Delete", new { id }));
            }
            catch
            {
                return(RedirectToAction("Error", "Home"));
            }
        }
 public void Delete(int invoiceId)
 {
     _repository.Delete(invoiceId);
 }
 public bool Delete(int InvoiceID, ref string err)
 {
     return(invoiceRepository.Delete(InvoiceID, ref err));
 }