コード例 #1
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);
        }
コード例 #2
0
ファイル: ImportExcelModel.cs プロジェクト: HungNV88/CRM
        public static ImportExcelModel FromInfo(ImportExcelInfo info)
        {
            ImportExcelModel retVal = new ImportExcelModel();

            retVal.Filename         = Path.GetFileName(info.FilePath);
            retVal.IsCorrectFormat  = retVal.Filename.ToLower().EndsWith(".xls") || retVal.Filename.ToLower().EndsWith(".xlsx");
            retVal.RowIndex         = info.RowIndex;
            retVal.TotalRow         = info.TotalRow;
            retVal.ErrorCount       = info.ErrorCount;
            retVal.CheckCount       = info.CheckCount;
            retVal.DuplicateCount   = info.DuplicateCount + info.InternalDuplicateCount;
            retVal.NoDuplicateCount = retVal.TotalRow - retVal.ErrorCount - retVal.DuplicateCount;
            retVal.ImportedDate     = info.ImportedDate;
            retVal.Status           = info.Status;
            retVal.ImportStatus     = info.ImportStatus;
            var sourceType = SourceTypeRepository.GetInfo(info.TypeId);

            if (sourceType != null)
            {
                retVal.SourceTypeName = sourceType.Name;
            }
            var channel = ChannelRepository.GetInfo(info.ChannelId);

            if (channel != null)
            {
                retVal.ChannelName = channel.Name;
            }
            var branch = BranchRepository.GetInfo(info.BranchId);

            if (branch != null)
            {
                retVal.BranchName = branch.Name;
            }
            var collector = CollectorRepository.GetInfo(info.CollectorId);

            if (collector != null)
            {
                retVal.CollectorName = collector.Name;
            }
            return(retVal);
        }
コード例 #3
0
 // GET api/<controller>/5
 public BranchInfo Get(int id)
 {
     return(BranchRepository.GetInfo(id));
 }