Exemple #1
0
        public bool Create(VM.CompanyModel model)
        {
            MD.tbl_Company company = new MD.tbl_Company();
            //UserInfo userBL = new UserInfo();

            company.Name           = model.Name.Trim();
            company.Code           = model.Code.Trim();
            company.Description    = model.Description;
            company.ProcessingTime = DateTime.Now - DateTime.Now.AddHours(-1); //TimeSpan.Parse(model.ProcessingHour + ":" + model.ProcessingMinute);
            company.SendTime       = DateTime.Now - DateTime.Now.AddHours(-1); //TimeSpan.Parse(model.SendHour + ":" + model.SendMinute);
            company.SendUrl        = "";
            company.EmailAddress   = "";
            company.CreatedBy      = "sysadmin";//model.CreatedBy;
            company.CreatedDate    = DateTime.Now;
            company.Rate           = model.Rate;
            company.Fee            = model.Fee;
            company.DocumentMaker  = "";
            //userBL.UpdateUserCompany(allSelectList);
            Ctx.tbl_Company.Add(company);
            try
            {
                Ctx.SaveChanges();
                return(true);
            }
            catch (DbEntityValidationException ex)
            {
                return(false);
            }
        }
Exemple #2
0
        public bool Update(VM.CompanyModel model, string allSelectList, int currCompanyId, string logonName)
        {
            MD.tbl_Company company = Ctx.tbl_Company.First(c => c.ID == model.ID && c.IsDeleted != true);
            company.Name           = model.Name.Trim();
            company.Code           = model.Code.Trim();
            company.Description    = model.Description;
            company.ProcessingTime = DateTime.Now - DateTime.Now.AddHours(-1);;
            company.SendTime       = DateTime.Now - DateTime.Now.AddHours(-1);;
            company.SendUrl        = model.SendUrl;
            company.EmailAddress   = model.EmailAddress;
            company.Rate           = model.Rate;
            company.Fee            = model.Fee;
            company.DocumentMaker  = model.DocumentMaker;

            company.UpdatedBy   = model.UpdatedBy;
            company.UpdatedDate = DateTime.Now;
            // 用户公司关系
            UpdateUserCompany(allSelectList, currCompanyId, logonName);
            Ctx.SaveChanges();
            return(true);
        }