コード例 #1
0
        public string Update(Profile profile)
        {
            var p = DbContext.CreateQuery <Profile>("Profile").FirstOrDefault(c => c.OpenId == profile.OpenId &&
                                                                              c.IdType == profile.IdType);

            if (p == null)
            {
                profile.LogOnTime    = DateTime.Now;
                profile.RegisterTime = DateTime.Now;
                profile.Role         = "User";
                profile.Id           = Guid.NewGuid().ToString();
                DbContext.AddObject("Profile", profile);
                DbContext.SaveChanges();
                return(profile.Id);
            }
            var newp = p;

            newp.Name = profile.Name;
            //TODo:
            if (profile.Name == "Öصä")
            {
                newp.Role = "Admin";
            }
            newp.NickName      = profile.NickName;
            newp.School        = profile.School;
            newp.SchoolDetails = profile.SchoolDetails;
            newp.Sex           = profile.Sex;
            DbContext.UpdateObject(newp);
            DbContext.SaveChanges();
            return(p.Id);
        }
コード例 #2
0
ファイル: GroupDao.cs プロジェクト: chteam/choj
 public void Add(Group group)
 {
     group.BeginTime = DateTime.Now;
     group.EndTime   = DateTime.Now;
     group.Id        = Guid.NewGuid().ToString();
     DbContext.AddObject("Group", group);
     DbContext.SaveChanges();
 }
コード例 #3
0
ファイル: AdminController.cs プロジェクト: jeswin/CanYouCode
        public ActionResult CreateMarketingAccounts(FormCollection coll)
        {
            var type    = coll["Type"];
            var company = Company.Create(coll["CompanyName"],
                                         Common.FixUrl(coll["Website"]), coll["City"], coll["Country"], coll["Username"], Common.RandomString(10),
                                         null, CURRENCY.USD, coll["Email"], coll["Phone"], type, Tenant.Id, DbContext);

            company.Description = coll["Description"];

            //account should not be active.
            company.Account.Status = ACCOUNT_STATUS.DISABLED;
            //reset the portfolio
            company.Portfolio.Clear();
            //We reset the password to "";
            company.Account.Password = "";
            if (Request.Files["Logo"] != null && Request.Files["Logo"].ContentLength > 0)
            {
                company.SaveLogo(Request.Files["Logo"] as HttpPostedFileBase);
            }

            var name = type == COMPANY_TYPE.INDIVIDUAL ? coll["CompanyName"] : "John Doe";

            company.AddConsultant(name, "Vice President", "http://www.linkedin.com/changethis", null, null, null, null);

            var portfolioEntryIds = coll.AllKeys.Where(k => k.StartsWith("Title_")).Select(t => Convert.ToInt32(t.Replace("Title_", ""))).ToList();

            foreach (var id in portfolioEntryIds)
            {
                if (Request.Files["Image_" + id].ContentLength > 0)
                {
                    company.Add_ImageAndDescription_Page(coll["Title_" + id], coll["Description_" + id], Request.Files["Image_" + id]);
                }
            }

            var token = Token.Create(TOKEN_TYPE.MARKETING_INVITE, coll["Username"], Tenant.Id);

            DbContext.AddObject(token);
            DbContext.SaveChanges();

            return(View <CreateMarketingAccounts>(GetViewName("CreateMarketingAccounts"), v =>
            {
                // can't pass parameters to show a message, so using the Add Error
                v.AddError(MessageCodes.ACCOUNT_CREATED_FOR_MARKETING,
                           string.Format("http://canyoucode.com/Companies/Preview?key={1}", coll["Username"], token.Key),
                           coll["Email"]);
            }));
        }