コード例 #1
0
ファイル: BranchController.cs プロジェクト: juancho618/Cargo
        public ActionResult ToggleState(string id)
        {
            var response = new JsonResultBody();

            try
            {
                Branch country = _repository.GetBranchById(id);
                response.Data = _repository.Delete(country);
            }
            catch (DbEntityValidationException ex)
            {
                response.Status = System.Net.HttpStatusCode.InternalServerError;
                foreach (DbEntityValidationResult result in ex.EntityValidationErrors)
                {
                    response.Errors = (from ve in result.ValidationErrors select ve.ErrorMessage).ToList();
                }
            }
            catch (Exception exApp)
            {
                response.Status = System.Net.HttpStatusCode.InternalServerError;
                response.Errors.Add(exApp.Message);
            }

            return(Json(response));
        }
コード例 #2
0
        public bool Delete(Branch branch)
        {
            int rowAffected = branchRepository.Delete(branch);

            bool isSaved = rowAffected > 0;

            return(isSaved);
        }
コード例 #3
0
        //Get Delete
        public bool Delete(int Id)
        {
            var isDelete = false;

            isDelete = _branchReository.Delete(Id);
            if (isDelete)
            {
                return(true);
            }
            return(isDelete);
        }
コード例 #4
0
ファイル: BlBranch.cs プロジェクト: sabounjirony/DeirElAhmar
        public bool Delete(long userId, Branch toDelete)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Delete(toDelete);

                BlLog.Log(userId, Module, "Delete branch", "BranchDeleted", new object[] { toDelete.Id });
                tran.Complete();
                return(toRet);
            }
        }
コード例 #5
0
ファイル: BranchBO.cs プロジェクト: 6624465/HREZY
 public void Delete(Branch branch)
 {
     try
     {
         branchRepository.Delete(branch);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #6
0
        public ActionResult Delete(int id)
        {
            var isDeleted = _branchRepository.Delete(id);

            if (!isDeleted)
            {
                ViewBag.Message = "Could not delete branch. Employees are assined to it.";
                List <Branch> branches = _branchRepository.Get();
                return(View("Index", branches));
            }
            return(RedirectToAction("Index"));
        }
コード例 #7
0
        public string Edit(FormDataCollection form)
        {
            var retVal    = string.Empty;
            var operation = form.Get("oper");
            var id        = ConvertHelper.ToInt32(form.Get("BranchId"));

            if (!string.IsNullOrEmpty(operation))
            {
                BranchInfo info;
                switch (operation)
                {
                case "edit":
                    info = BranchRepository.GetInfo(id);
                    if (info != null)
                    {
                        info.Code        = form.Get("Code");
                        info.Name        = form.Get("Name");
                        info.LocationID  = ConvertHelper.ToInt32(form.Get("LocationName"));
                        info.Description = form.Get("Description");
                        //info.Status = form.Get("Status");
                        info.ChangedBy = UserRepository.GetCurrentUserInfo().UserID;
                        BranchRepository.Update(info);
                    }
                    break;

                case "add":
                    info = new BranchInfo
                    {
                        Code        = form.Get("Code"),
                        Name        = form.Get("Name"),
                        LocationID  = ConvertHelper.ToInt32(form.Get("LocationName")),
                        Description = form.Get("Description"),
                        //Status = form.Get("Status"),
                        CreatedBy = UserRepository.GetCurrentUserInfo().UserID
                    };

                    BranchRepository.Create(info);
                    break;

                case "del":
                    BranchRepository.Delete(id, UserRepository.GetCurrentUserInfo().UserID);
                    break;
                }
            }
            //StoreData.ListBranch = BranchRepository.GetAll();
            return(retVal);
        }
コード例 #8
0
 public IHttpActionResult Delete(int id)
 {
     branchRepository.Delete(id);
     return(StatusCode(HttpStatusCode.NoContent));
 }
コード例 #9
0
 public ActionResult DeleteConfirmed(Guid id)
 {
     m_branchRepository.Delete(id);
     return(RedirectToAction("Index"));
 }
コード例 #10
0
 public async Task Delete_BranchNameIsNull_ThrowsArgumentNullException()
 {
     await Assert.ThrowsAsync <ArgumentNullException>(() => _sut.Delete(0, null));
 }