Example #1
0
        public void SetImmediateSupervisor(string account, string userID)
        {
            if (String.IsNullOrEmpty(userID))
            {
                throw new ArgumentNullException("userID不能为空");
            }

            var supervisor = GetUserImmediateSupervisor(account);

            if (supervisor == null || supervisor.ID == string.Empty.ToString())
            {
                supervisor = new ImmediateSupervisorSettings();

                supervisor.ID      = Guid.NewGuid().ToString();
                supervisor.Account = account;
                supervisor.UserID  = userID;

                GenericService.Add(supervisor);
                GenericService.Save();
            }
            else
            {
                supervisor.UserID = userID;

                GenericService.Update(supervisor);
                GenericService.Save();
            }
        }
Example #2
0
        public void SureRendingReply(Guid itemId)
        {
            var item = GenericService.GetModel(itemId);

            if (item == null)
            {
                throw new Exception("用户不存在,或已被删除!");
            }

            item.ApplyState = 99;

            var newItem = new DZAFCPortal.Entity.MyFriends();

            newItem.ID              = Guid.NewGuid().ToString();
            newItem.UserAccount     = item.MyFriendAccount;
            newItem.MyFriendAccount = item.UserAccount;
            newItem.ApplyState      = 99;

            //判断用户是否在另一用户列表中
            var _temp = GenericService.GetAll(p => p.UserAccount == newItem.UserAccount && p.MyFriendAccount == newItem.MyFriendAccount).FirstOrDefault();

            if (_temp != null)
            {
                _temp.ApplyState = 99;
                GenericService.Update(_temp);
            }
            else
            {
                GenericService.Add(newItem);
            }

            GenericService.Save();
        }
Example #3
0
        public void AddMethod_NullEntity_ThrowsException()
        {
            var repoAddCalls = productRepoCalls["Add"];

            try
            {
                productService.Add(null);
                Assert.Fail("Expected ArgumentNullException but none thrown");
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOf <ArgumentNullException>(ex);
                Assert.AreEqual("entity", ((ArgumentNullException)ex).ParamName);

                // make sure underlying repository .Add hasn't been called.
                Assert.AreEqual(repoAddCalls, productRepoCalls["Add"]);
            }
        }
Example #4
0
        public ActionResult Create(ProductFeatureViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var feature = new ProductFeature {
                    ProductId = vm.ProductId
                };
                converter.ViewmodelToEntity(vm, ref feature);

                service.Add(feature);

                return(RedirectToAction("Edit", "Product", new { id = feature.ProductId }));
            }
            else
            {
                return(View(vm));
            }
        }
Example #5
0
        public ActionResult Create(ProductVersionViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var version = new ProductVersion {
                    ProductId = vm.ProductId
                };
                converter.ViewmodelToEntity(vm, ref version);

                service.Add(version);

                return(RedirectToAction("Edit", "Product", new { id = version.ProductId }));
            }
            else
            {
                return(View(vm));
            }
        }
Example #6
0
        public IActionResult AddCourse([FromBody] Course course)
        {
            course.Id         = Guid.NewGuid().ToString();
            course.Created    = DateTime.Now;
            course.Modified   = DateTime.Now;
            course.CreatedBy  = "system";
            course.ModifiedBy = "system";
            course.IsActive   = true;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            bool added = _service.Add(course);

            if (added)
            {
                return(Ok(course.Id));
            }

            return(BadRequest("Couldn't save course."));
        }
Example #7
0
 public virtual void Add([FromForm] T entity)
 {
     services.Add(entity);
 }
 public virtual void Add(T entity)
 {
     service.Add(entity);
 }
Example #9
0
 void AddAccessRight(AccessRight rights)
 {
     _accessRightService.Add(rights);
 }
Example #10
0
        static void Main(string[] args)
        {
            GenericService <Item> genericItemService = new GenericService <Item>();

            Item itemForGeneric  = new Item(1, "Apple");
            Item item2ForGeneric = new Item(2, "Strawberry");

            genericItemService.Add(itemForGeneric);
            genericItemService.Add(item2ForGeneric);

            var items = genericItemService.GetAll();


            genericItemService.Remove(item2ForGeneric);

            GenericService <MenuAction> genericActionService = new GenericService <MenuAction>();
            MenuAction menuAction = new MenuAction(1);

            genericActionService.Add(menuAction);

            MenuActionService actionService = new MenuActionService();
            ItemService       itemService   = new ItemService();

            actionService = Initialize(actionService);

            Console.WriteLine("Welcome to warehouse app!");
            while (true)
            {
                Console.WriteLine("Please let me know what you want to do:");
                var mainMenu = actionService.GetMenuActionsByMenuName("Main");
                for (int i = 0; i < mainMenu.Count; i++)
                {
                    Console.WriteLine($"{mainMenu[i].Id}. {mainMenu[i].Name}");
                }

                var operation = Console.ReadKey();

                switch (operation.KeyChar)
                {
                case '1':
                    var keyInfo = itemService.AddNewItemView(actionService);
                    var id      = itemService.AddNewItem(keyInfo.KeyChar);
                    break;

                case '2':
                    var removeId = itemService.RemoveItemView();
                    itemService.RemoveItem(removeId);
                    break;

                case '3':
                    var detailId = itemService.ItemDetailSelectionView();
                    itemService.ItemDetailView(detailId);
                    break;

                case '4':
                    var typeId = itemService.ItemTypeSelectionView();
                    itemService.ItemsByTypeIdView(typeId);
                    break;

                default:
                    Console.WriteLine("Action you entered does not exist");
                    break;
                }
            }
        }