Exemplo n.º 1
0
        public void Insert(PositionViewModelRequest viewModel)
        {
            var model = _mapper.Map <Position>(viewModel);

            _positionRepository.Add(model);

            _unitOfWork.Commit();
        }
Exemplo n.º 2
0
        public virtual ActionResult CreatePosition(Position model)
        {
            model.IsActive = true;
            _positionRepository.Add(model);
            _unitOfWork.Commit();

            return(RedirectToAction("Position"));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> PostPosition([FromBody] Position position)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _positionRepository.Add(position);

            return(CreatedAtAction("PostPosition", new { id = position.PositionId }, position));
        }
Exemplo n.º 4
0
        public void PositionRepository_AddTest()
        {
            IPositionRepository positionRepository = IoCFactory.Instance.CurrentContainer.Resolve <IPositionRepository>();
            Position            position1          = new Position()
            {
                Id    = new Guid("0c11fc14-c881-c335-e1e8-08d1b45385cd"),
                Title = "testPosition"
            };

            positionRepository.Add(position1);
            positionRepository.UnitOfWork.Commit();
            Position byId = positionRepository.GetElementById(position1.Id);

            Assert.IsNotNull((object)byId);
            Assert.IsTrue(byId.Id == position1.Id);
        }
 /// <summary>
 /// 添加或修改
 /// </summary>
 /// <param name="model"></param>
 public void AddOrModity(Position model)
 {
     model.PyCode = model.PositionName.ToConvertPyCode();
     if (!string.IsNullOrEmpty(model.Id))
     {
         model.LastUpdateDate = DateTime.Now;
         positionRepository.Modity(model);
     }
     else
     {
         model.GenerateNewIdentity();
         model.CreateDate     = DateTime.Now;
         model.LastUpdateDate = DateTime.Now;
         positionRepository.Add(model);
     }
     positionRepository.SaveChanges();
 }
Exemplo n.º 6
0
        public override object Add(Position position)
        {
            // Validate dữ liệu
            var serviceResult = base.Validate(position);

            if (serviceResult != null)
            {
                return(serviceResult);
            }
            // Gọi hàm thêm mới khách hàng
            var rowEffects = _positionRepository.Add(position);

            return(new ServiceResult()
            {
                Data = rowEffects, MisaCode = MISACode.IsValid
            });
        }
Exemplo n.º 7
0
        public Position GetPosition(string name)
        {
            var position = positions[name.ToLower()] as Position;

            if (position == null)
            {
                Position position1 = new Position
                {
                    Name = name
                };
                _repository.Add(position1);
                position = position1;
            }


            return(position);
        }
Exemplo n.º 8
0
        public async Task Add(List <Position> positions)
        {
            Tournament tournament = await _tournamentRepository.Get(positions[0].TournamentID);

            foreach (Position position in positions)
            {
                await _positionRepository.Add(position);

                if (position.Qualified || position.NoPosition == 1)
                {
                    Team team = await _teamRepository.Get(position.TeamID);

                    switch (tournament.TournamentType.Format)
                    {
                    case TournamentFormat.Qualification:
                        team.WorldCupQualifications++;
                        break;

                    case TournamentFormat.WorldCup:
                        team.WorldCupTitles++;
                        break;

                    case TournamentFormat.ConfederationsCup:
                        team.ConfederationsCupTitles++;
                        break;

                    case TournamentFormat.ConfederationTournament:
                        team.ConfederationTournamentTitles++;
                        break;
                    }

                    _teamRepository.Update(team);
                }
            }

            await _positionRepository.SaveChanges();
        }
Exemplo n.º 9
0
 public void CreatePosition(Position position)
 {
     positionRepository.Add(position);
 }
Exemplo n.º 10
0
 public Position Add(Position entity)
 {
     return(_position.Add(entity));
 }
Exemplo n.º 11
0
 public Position Add(Position Position)
 {
     return(_PositionRepository.Add(Position));
 }
Exemplo n.º 12
0
        public int Upload(string fileName, out string returnMsg, bool isInitial = false)
        {
            ExcelPackage package;
            IList <Item> listOfItems = new List <Item>();

            returnMsg = string.Empty;

            //string strorageconn = System.Configuration.ConfigurationSettings.AppSettings.Get("StorageConnectionString");
            //CloudStorageAccount storageacc = CloudStorageAccount.Parse(strorageconn);
            //CloudBlobClient blobClient = storageacc.CreateCloudBlobClient();
            //CloudBlobContainer container = blobClient.GetContainerReference("itemimages");

            if (isInitial)
            {
                var excelFile      = Resource.仓库物品资料汇总表;
                var templateStream = new MemoryStream(excelFile);
                package = new ExcelPackage(templateStream);
            }
            else
            {
                if (string.IsNullOrEmpty(fileName))
                {
                    return(-2);
                }
                var fi = new FileInfo(fileName);
                package = new ExcelPackage(fi);
            }
            var workbook  = package.Workbook;
            var worksheet = workbook.Worksheets["物品资料汇总表"];

            if (worksheet == null)
            {
                return(0);
            }
            InitalImagesToLocal(_resourceName, worksheet);
            var end = worksheet.Dimension.End;

            for (var row = 9; row < end.Row; row++)
            {
                var itemObject = new Item
                {
                    ItemId = Guid.NewGuid(),
                    DefaultPositionName = "Stage",
                    UpdateDate          = DateTime.Now
                };
                for (var col = 1; col <= worksheet.Dimension.End.Column; col++)
                {
                    var readValue = worksheet.Cells[row, col].Value == null ? "" : worksheet.Cells[row, col].Value.ToString();
                    switch (col)
                    {
                    case 1:
                        if (readValue == "")
                        {
                            break;
                        }
                        else
                        {
                            itemObject.SerialNumber = int.Parse(readValue);     //序号
                        }
                        break;

                    case 3:
                        itemObject.Code = readValue;     // 编号
                        break;

                    case 4:
                        itemObject.Status = readValue;      //状态
                        if (readValue.Contains("Active"))
                        {
                            itemObject.Status = "现行Active";
                        }
                        else if (readValue.Contains("Discountinue"))
                        {
                            itemObject.Status = "中止Discountinue";
                        }
                        else if (readValue.Contains("Cancel"))
                        {
                            itemObject.Status = "取消Cancel";
                        }
                        else if (readValue.Contains("Deactive"))
                        {
                            itemObject.Status = "下线Deactive";
                        }
                        else
                        {
                            itemObject.Status = "";
                        }
                        break;

                    case 5:
                        itemObject.Category = readValue;     //物品类别
                        break;

                    case 6:
                        itemObject.ProjectCategory = readValue;     //所属转项类
                        break;

                    case 7:
                        itemObject.SubCategory = readValue;    //物品种类
                        break;

                    case 8:
                        itemObject.BigCategory = readValue;     //物品大类
                        break;

                    case 9:
                        itemObject.SmallCategory = readValue;    //物品小类
                        break;

                    case 10:
                        itemObject.DetailCategory = readValue;     //物品细类
                        break;

                    case 11:
                        itemObject.AdjustCategory = readValue;     //调整类
                        break;

                    case 12:
                        itemObject.Attribute = readValue;    //物品属性
                        break;

                    case 13:
                        itemObject.Property = readValue;    //资产类型
                        break;

                    case 14:
                        itemObject.ChineseName = readValue.Replace("\n", " ");    //中文名
                        break;

                    case 15:
                        itemObject.EnglishName = readValue.Replace("\n", " ");    //英文名
                        break;

                    case 16:
                        break;

                    case 17:
                        itemObject.Brand = readValue;     //品牌
                        break;

                    case 18:
                        itemObject.Model = readValue;     //型号
                        break;

                    case 19:
                        itemObject.Specification = readValue;     //规格
                        break;

                    case 20:
                        itemObject.Dimension = readValue;     //尺寸
                        break;

                    case 21:
                        itemObject.Length = readValue;     //长
                        break;

                    case 22:
                        itemObject.Width = readValue;     //宽
                        break;

                    case 23:
                        itemObject.Height = readValue;     //高
                        break;

                    case 25:
                        itemObject.Unit = readValue;     //单位
                        break;

                    case 26:
                        if (readValue == "")
                        {
                            itemObject.Price = 0;
                        }
                        else
                        {
                            itemObject.Price = double.Parse(readValue);     //单价
                        }
                        break;

                    case 27:
                        itemObject.Package = readValue;     //包装数量
                        break;

                    case 28:
                        itemObject.PackageLength = readValue;     //包装长
                        break;

                    case 29:
                        itemObject.PackageWidth = readValue;     //包装宽
                        break;

                    case 30:
                        itemObject.PackageHeight = readValue;     //包装高
                        break;

                    case 31:
                        itemObject.Detail = readValue;     //详细信息链接
                        break;

                    case 35:
                        if (readValue == "")
                        {
                            itemObject.Max = 0;
                        }
                        else
                        {
                            itemObject.Max = double.Parse(readValue);     //库存上限
                        }
                        break;

                    case 36:
                        if (readValue == "")
                        {
                            itemObject.Min = 0;
                        }
                        else
                        {
                            itemObject.Min = double.Parse(readValue);     //库存下限
                        }
                        break;

                    case 38:
                        itemObject.FirstSupplier = readValue.TrimEnd().TrimStart();     // 一级供应商
                        break;

                    case 41:
                        itemObject.SecondSupplier = readValue.TrimEnd().TrimStart();     // 二级供应商
                        break;

                    case 44:
                        itemObject.ThirdSupplier = readValue.TrimEnd().TrimStart();     // 三级供应商
                        break;

                    case 48:
                        itemObject.CostCategory = readValue;
                        break;

                    case 50:
                        itemObject.ArrangeOrder = readValue;
                        break;

                    case 51:
                        itemObject.ArrangePosition = readValue;
                        break;
                    }
                }

                if (itemObject.SerialNumber > 0)
                {
                    listOfItems.Add(itemObject);
                }
            }


            try
            {
                var existingItems     = _itemRepository.GetAll();
                var existingPositions = _positionRepository.GetAll();

                if (!existingItems.Any())
                {
                    _itemRepository.CleanUp();
                    _itemRepository.AddRange(listOfItems);
                }
                else
                {
                    foreach (var item in listOfItems)
                    {
                        var existingItem = existingItems.FirstOrDefault(x => x.Code == item.Code);
                        if (existingItem != null)
                        {
                            existingItem.Status          = item.Status;
                            existingItem.Category        = item.Category;
                            existingItem.ProjectCategory = item.ProjectCategory;
                            existingItem.SubCategory     = item.SubCategory;
                            existingItem.BigCategory     = item.BigCategory;
                            existingItem.SmallCategory   = item.SmallCategory;
                            existingItem.DetailCategory  = item.DetailCategory;
                            existingItem.AdjustCategory  = item.AdjustCategory;
                            existingItem.Attribute       = item.Attribute;
                            existingItem.Property        = item.Property;
                            existingItem.ChineseName     = item.ChineseName;
                            existingItem.EnglishName     = item.EnglishName;
                            existingItem.Brand           = item.Brand;
                            existingItem.Model           = item.Model;
                            existingItem.Specification   = item.Specification;
                            existingItem.Dimension       = item.Dimension;
                            existingItem.Length          = item.Length;
                            existingItem.Width           = item.Width;
                            existingItem.Height          = item.Height;
                            existingItem.Unit            = item.Unit;
                            existingItem.Price           = item.Price;
                            existingItem.Package         = item.Package;
                            existingItem.PackageLength   = item.PackageLength;
                            existingItem.PackageWidth    = item.PackageWidth;
                            existingItem.PackageHeight   = item.PackageHeight;
                            existingItem.Detail          = item.Detail;
                            existingItem.Max             = item.Max;
                            existingItem.Min             = item.Min;
                            existingItem.CostCategory    = item.CostCategory;
                            existingItem.ArrangeOrder    = item.ArrangeOrder;
                            existingItem.ArrangePosition = item.ArrangePosition;
                            existingItem.Comments        = item.Comments;
                            existingItem.FirstSupplier   = item.FirstSupplier;
                            existingItem.SecondSupplier  = item.SecondSupplier;
                            existingItem.ThirdSupplier   = item.ThirdSupplier;
                        }
                        else
                        {
                            var positionObject = new Position()
                            {
                                ItemId       = item.ItemId,
                                Code         = item.Code,
                                PositionName = "Stage"
                            };
                            _positionRepository.Add(positionObject);
                            _itemRepository.Add(item);
                        }
                    }
                }
                _itemRepository.Save();
                _positionRepository.Save();

                return(1);
            }
            catch (Exception)
            {
                return(0);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Seed method attempts to intsert the initial data into the database everytime when database is being updated after migration
        /// </summary>
        /// <param name="context">Database context on which seed method is being called (Not used in this scenario because repositories are used to insert the data)</param>
        protected override void Seed(RAMS.Data.DataContext context)
        {
            // Add users
            using (var applicationDbContext = new ApplicationDbContext())
            {
                var userStore = new UserStore <ApplicationUser>(applicationDbContext);

                var userManager = new UserManager <ApplicationUser>(userStore);

                if (userManager.FindByName("john.doe") == null)
                {
                    var users = GetUsers();

                    foreach (var user in users)
                    {
                        userManager.Create(user, "123RAMSApp!");

                        // Add user claims for each user
                        if (user.UserName == "superuser")
                        {
                            userManager.AddClaim(user.Id, new Claim("FullName", "superuser"));
                            userManager.AddClaim(user.Id, new Claim("Role", "Manager"));
                            userManager.AddClaim(user.Id, new Claim("UserType", "Admin"));
                            userManager.AddClaim(user.Id, new Claim("UserStatus", "Active"));
                        }
                        else if (user.UserName == "john.doe")
                        {
                            userManager.AddClaim(user.Id, new Claim("FullName", "John Doe"));
                            userManager.AddClaim(user.Id, new Claim("Role", "Manager"));
                            userManager.AddClaim(user.Id, new Claim("UserType", "Agent"));
                            userManager.AddClaim(user.Id, new Claim("UserStatus", "Active"));
                        }
                        else if (user.UserName == "james.smith")
                        {
                            userManager.AddClaim(user.Id, new Claim("FullName", "James Smith"));
                            userManager.AddClaim(user.Id, new Claim("Role", "Employee"));
                            userManager.AddClaim(user.Id, new Claim("UserType", "Agent"));
                            userManager.AddClaim(user.Id, new Claim("UserStatus", "Active"));
                        }
                        else if (user.UserName == "mary.watson")
                        {
                            userManager.AddClaim(user.Id, new Claim("FullName", "Mary Watson"));
                            userManager.AddClaim(user.Id, new Claim("Role", "Employee"));
                            userManager.AddClaim(user.Id, new Claim("UserType", "Agent"));
                            userManager.AddClaim(user.Id, new Claim("UserStatus", "Active"));
                        }
                        else if (user.UserName == "tommy.jordan")
                        {
                            userManager.AddClaim(user.Id, new Claim("FullName", "Tommy Jordan"));
                            userManager.AddClaim(user.Id, new Claim("Role", "Employee"));
                            userManager.AddClaim(user.Id, new Claim("UserType", "Admin"));
                            userManager.AddClaim(user.Id, new Claim("UserStatus", "Active"));
                        }
                        else if (user.UserName == "kathy.doe")
                        {
                            userManager.AddClaim(user.Id, new Claim("FullName", "Kathy Doe"));
                            userManager.AddClaim(user.Id, new Claim("Role", "Employee"));
                            userManager.AddClaim(user.Id, new Claim("UserType", "Admin"));
                            userManager.AddClaim(user.Id, new Claim("UserStatus", "Active"));
                        }
                        else if (user.UserName == "jimmy.thomson")
                        {
                            userManager.AddClaim(user.Id, new Claim("FullName", "Jimmy Thomson"));
                            userManager.AddClaim(user.Id, new Claim("Role", "Employee"));
                            userManager.AddClaim(user.Id, new Claim("UserType", "Client"));
                            userManager.AddClaim(user.Id, new Claim("UserStatus", "Active"));
                        }
                        else if (user.UserName == "nancy.clinton")
                        {
                            userManager.AddClaim(user.Id, new Claim("FullName", "Nancy Clinton"));
                            userManager.AddClaim(user.Id, new Claim("Role", "Employee"));
                            userManager.AddClaim(user.Id, new Claim("UserType", "Client"));
                            userManager.AddClaim(user.Id, new Claim("UserStatus", "Active"));
                        }
                    }
                }
            }

            // Add departments
            if (!departmentRepository.GetAll().Any())
            {
                GetDepartments().ForEach(d => departmentRepository.Add(d));

                unitOfWork.Commit();
            }

            // Add agents
            if (!agentRepository.GetAll().Any())
            {
                GetAgents().ForEach(a => agentRepository.Add(a));

                unitOfWork.Commit();
            }

            // Add clients
            if (!clientRepository.GetAll().Any())
            {
                GetClients().ForEach(c => clientRepository.Add(c));

                unitOfWork.Commit();
            }

            // Add admins
            if (!adminRepository.GetAll().Any())
            {
                GetAdmins().ForEach(a => adminRepository.Add(a));

                unitOfWork.Commit();
            }

            // Add categories
            if (!categoryRepository.GetAll().Any())
            {
                GetCategories().ForEach(c => categoryRepository.Add(c));

                unitOfWork.Commit();
            }

            // Add positions
            if (!positionRepository.GetAll().Any())
            {
                GetPositions().ForEach(p => positionRepository.Add(p));

                unitOfWork.Commit();
            }

            // Add candidates
            if (!candidateRepository.GetAll().Any())
            {
                GetCandidates().ForEach(c => candidateRepository.Add(c));

                unitOfWork.Commit();
            }

            // Add interiews
            if (!interviewRepository.GetAll().Any())
            {
                GetInterviews().ForEach(i => interviewRepository.Add(i));

                unitOfWork.Commit();
            }

            // Add notifications
            if (!notificationRepository.GetAll().Any())
            {
                GetNotifications().ForEach(n => notificationRepository.Add(n));

                unitOfWork.Commit();
            }
        }