Beispiel #1
0
        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));
        }
Beispiel #2
0
        public bool Delete(Branch branch)
        {
            int rowAffected = branchRepository.Delete(branch);

            bool isSaved = rowAffected > 0;

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

            isDelete = _branchReository.Delete(Id);
            if (isDelete)
            {
                return(true);
            }
            return(isDelete);
        }
Beispiel #4
0
        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);
            }
        }
Beispiel #5
0
 public void Delete(Branch branch)
 {
     try
     {
         branchRepository.Delete(branch);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        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"));
        }
Beispiel #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);
        }
Beispiel #8
0
 public IHttpActionResult Delete(int id)
 {
     branchRepository.Delete(id);
     return(StatusCode(HttpStatusCode.NoContent));
 }
 public ActionResult DeleteConfirmed(Guid id)
 {
     m_branchRepository.Delete(id);
     return(RedirectToAction("Index"));
 }
Beispiel #10
0
 public async Task Delete_BranchNameIsNull_ThrowsArgumentNullException()
 {
     await Assert.ThrowsAsync <ArgumentNullException>(() => _sut.Delete(0, null));
 }