public void SetRating(PartnerCompany targetcompany, decimal rating)
 {
     var companyrating = new CompanyRating { PartnerCompany = targetcompany, Rating = rating };
     targetcompany.CompanyRatings.Add(companyrating);
        // _rep.Add(companyrating);
     _rep.Save();
 }
        private void FixupPartnerCompany(PartnerCompany previousValue)
        {
            if (previousValue != null && previousValue.CompanyRatings.Contains(this))
            {
                previousValue.CompanyRatings.Remove(this);
            }

            if (PartnerCompany != null)
            {
                if (!PartnerCompany.CompanyRatings.Contains(this))
                {
                    PartnerCompany.CompanyRatings.Add(this);
                }
                if (CompanyId != PartnerCompany.Id)
                {
                    CompanyId = PartnerCompany.Id;
                }
            }
        }
예제 #3
0
        private void FixupFirstCompany(PartnerCompany previousValue)
        {
            if (previousValue != null && previousValue.Contracts.Contains(this))
            {
                previousValue.Contracts.Remove(this);
            }

            if (FirstCompany != null)
            {
                if (!FirstCompany.Contracts.Contains(this))
                {
                    FirstCompany.Contracts.Add(this);
                }
                if (CompanyId != FirstCompany.Id)
                {
                    CompanyId = FirstCompany.Id;
                }
            }
        }
        private void FixupPlanCompany(PartnerCompany previousValue)
        {
            if (previousValue != null && previousValue.EquipmentOrders_1.Contains(this))
            {
                previousValue.EquipmentOrders_1.Remove(this);
            }

            if (PlanCompany != null)
            {
                if (!PlanCompany.EquipmentOrders_1.Contains(this))
                {
                    PlanCompany.EquipmentOrders_1.Add(this);
                }
                if (PlanCompanyId != PlanCompany.Id)
                {
                    PlanCompanyId = PlanCompany.Id;
                }
            }
            else if (!_settingFK)
            {
                PlanCompanyId = null;
            }
        }
 /// <summary>
 /// 按照公司名称查找公司代码,如果是新的供应商,
 /// 则建立新的供应商记录,并且标识为新的供应商,待完善档案资质文件等。
 /// </summary>
 /// <param name="companyname">公司名称</param>
 /// <returns>公司代码</returns>
 private int GetEqCompanyId(string companyname)
 {
     var company = Repository.SingleOrDefault<PartnerCompany>(x => x.Name.Trim() == companyname.Trim());
     if (company != null)
     {
         return company.Id;
     }
     company = new PartnerCompany
     {
         Name = companyname,
         CreatBy = CurrentUser.UserName,
         CreatedOn = DateTime.Now,
         LevelType = 1,
         PartnerType = 1,  // 标识为设备供应商
         IsActive = true,
         AuthorizedTypeId = 3,
         AuthorizedOn = DateTime.Now,
         IsApproval = false// 标志该项目是新进来的,待批准
     };
     Repository.Add(company);
     Repository.Save();
     return company.Id;
 }
 public virtual ActionResult Create(Company tosave)
 {
     try
     {
         if (ModelState.IsValid){
             var newcompany = new PartnerCompany();
             TryUpdateModel(newcompany);
             Repository.Add(newcompany);
             Repository.Save();
             return RedirectToAction(MVC.Company.ListVendors());
         }
         var types = Repository.All<AuthorizedType>().ToList();
         var businesstypes = Repository.All<BussinessType>().ToList();
         ViewData["AuthorizedTypes"] = Mapper.Map<IList<AuthorizedType>, IList<AuthorizedTypeView>>(types);
         ViewData["BusinessTypes"] = businesstypes;
         return View(tosave);
     }
     catch (Exception)
     {
         var types = Repository.All<AuthorizedType>().ToList();
         var businesstypes = Repository.All<BussinessType>().ToList();
         ViewData["AuthorizedTypes"] = Mapper.Map<IList<AuthorizedType>, IList<AuthorizedTypeView>>(types);
         ViewData["BusinessTypes"] = businesstypes;
         return View(tosave);
     }
 }
예제 #7
0
 public CompanyDetailView(PartnerCompany company)
 {
     CompanyView = Mapper.Map<PartnerCompany, Company>(company);
     // Certifications = company.Certifications.ToList();
 }
        private void FixupPartnerCompany(PartnerCompany previousValue)
        {
            if (previousValue != null && previousValue.SubContracts.Contains(this))
            {
                previousValue.SubContracts.Remove(this);
            }

            if (PartnerCompany != null)
            {
                if (!PartnerCompany.SubContracts.Contains(this))
                {
                    PartnerCompany.SubContracts.Add(this);
                }
                if (SubCompanyId != PartnerCompany.Id)
                {
                    SubCompanyId = PartnerCompany.Id;
                }
            }
            else if (!_settingFK)
            {
                SubCompanyId = null;
            }
        }