Exemplo n.º 1
0
        public void ActionsByInventarizationsWorks()
        {
//            DELETE FROM public."Tasks";
//DELETE FROM public."Users";
//DELETE FROM public."Actions";
//DELETE FROM public."Zones";
//DELETE FROM public."Inventorizations";
//DELETE FROM public."Companies"

            User user = userRepositoriy.CreateUser(new User()
            {
                FirstName = "test_name", FamilyName = "test_family", MiddleName = "test_middlename", Level = UserLevel.Scaner, CreatedAt = DateTime.UtcNow, Login = "******", Password = "******"
            });
            Company company = companyRepositoriy.CreateCompany("Тест1");

            Business.Model.Inventorization inventarisation = inventorizationRepositoriy.CreateInventorization(company.Id, DateTime.UtcNow);
            Guid firstActionId  = Guid.NewGuid();
            Guid secondActionId = Guid.NewGuid();

            Business.Model.Action firstAction = new Business.Model.Action()
            {
                Id              = firstActionId,
                DateTime        = DateTime.UtcNow,
                Type            = ActionType.FirstScan,
                UserId          = user.Id,
                Inventorization = inventarisation.Id,
                BarCode         = "1",
                Quantity        = 1,
            };

            Business.Model.Action secondAction = new Business.Model.Action()
            {
                Id       = firstActionId,
                DateTime = DateTime.UtcNow,
                Type     = ActionType.FirstScan,
                UserId   = user.Id,
                Zone     = inventarisation.Id,
                BarCode  = "1",
                Quantity = 1,
            };

            actionRepository.CreateAction(firstAction);
            actionRepository.CreateAction(secondAction);
            List <Business.Model.Action> actions = actionRepository.GetActionsByInventorization(inventarisation.Id);

            Assert.IsNotNull(actions);
            Assert.AreEqual(2, actions.Count());

            actionRepository.DeleteAction(firstActionId);
            actionRepository.DeleteAction(secondActionId);
            inventorizationRepositoriy.DeleteInventorization(inventarisation.Id);
            companyRepositoriy.DeleteCompany(company.Id);
            userRepositoriy.DeleteUser(user.Id);
        }
Exemplo n.º 2
0
        public ActionResult Delete(Guid id)
        {
            try
            {
                string companyId = string.Empty;

                companyId = companyRepository.DeleteCompany(id, LogInManager.LoggedInUserId);

                if (!string.IsNullOrWhiteSpace(companyId))
                {
                    return(Json(new
                    {
                        IsSuccess = true,
                        data = new
                        {
                            CompanyId = companyId
                        }
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        IsSuccess = false,
                        errorMessage = "Company details not deleted successfully."
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                Utility.Utility.LogError(e, "Delete");
                return(Json(new { IsSuccess = false, errorMessage = e.Message }));
            }
        }
Exemplo n.º 3
0
        public async Task <bool> DeleteCompany(int id)
        {
            if (!HttpContext.User.Identity.IsAuthenticated)
            {
                throw new ApiException("You have to be logged in to modify data", 401);
            }

            return(await CompanyRepo.DeleteCompany(id));
        }
Exemplo n.º 4
0
 public bool DeleteCompany(long companyAccountId)
 {
     try
     {
         return(_companyAccountRepository.DeleteCompany(companyAccountId));
     }
     catch (Exception ex)
     {
         ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
         return(false);
     }
 }
        public JsonResult Delete(int id)
        {
            using (var cRepository = new CompanyRepository())
            {
                bool bSuccess = cRepository.DeleteCompany(id);

                return(Json(new
                {
                    success = bSuccess
                },
                            JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 6
0
        public CheckResult DeleteCompany(CompanyModel model)
        {
            try
            {
                using (var db = DB.GetContext())
                {
                    var check = CompanyValidator.ValidateDelete(db, model);
                    if (check.Failed)
                    {
                        return(check);
                    }

                    CompanyRepository.DeleteCompany(db, model);
                    db.SaveChanges();
                    return(check);
                }
            }
            catch (Exception ex)
            {
                return(new CheckResult(ex));
            }
        }