Ejemplo n.º 1
0
        public ActionResult Create(CreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                Account account = GetAccount();
                Profile profile = new Profile
                {
                    accountID    = account.accountID,
                    jobID        = model.jobID,
                    businessName = model.businessName,
                    userName     = model.userName,
                    location     = model.location,
                    description  = model.description,
                    //startYear = model.startYear,
                    website        = model.website,
                    youtube        = model.youtube,
                    additionalInfo = model.additionalInfo,
                    isApproved     = false,
                    isSuspended    = false,
                    createDate     = DateTime.Now,
                };

                var existingUsername = profileDAL.FetchByUsername(model.userName);
                if (existingUsername != null)
                {
                    TempData["errorMessage"] = "That username already exists";
                    model.Jobs = jobDAL.FetchAll();
                    return(View(model));
                }
                else
                {
                    profileDAL.Create(profile);
                    return(RedirectToAction("AvatarUpload"));
                }
            }
            model.Jobs = jobDAL.FetchAll();
            return(View(model));
        }