Exemplo n.º 1
0
 public ActionResult PersonalRegister(AccountViewModel model)
 {
     try
     {
         if (model.Password != model.rePassword)
         {
             ViewBag.Message = "Şifreler uyuşmuyor";
         }
         else
         {
             Personal personal = new Personal();
             personal.FirstName  = model.FirstName;
             personal.LastName   = model.LastName;
             personal.BirthDate  = model.BirthDate;
             personal.Gender     = model.Gender;
             personal.HaveAPet   = model.HaveAPet;
             personal.PetCount   = model.PetCount;
             personal.Username   = model.Username;
             personal.EMail      = model.EMail;
             personal.Password   = model.Password;
             personal.Phone      = model.Phone;
             personal.Address    = model.Address;
             personal.UserRoleID = 2;
             personal.IsActive   = false;
             bool result = _personalService.Insert(personal);
         }
     }
     catch (Exception ex)
     {
         ViewBag.Message = ex.Message;
     }
     return(View("Login"));
 }
Exemplo n.º 2
0
        public ActionResult PersonalRegister(AccountViewModel model, HttpPostedFileBase fileUpload)
        {
            try
            {
                if (model.Password != model.RePassword)
                {
                    ViewBag.Message = "Şifreler uyuşmuyor";
                }
                else
                {
                    Personal personal = new Personal();
                    personal.FirstName  = model.FirstName;
                    personal.LastName   = model.LastName;
                    personal.BirthDate  = model.BirthDate;
                    personal.Gender     = model.Gender;
                    personal.PetCount   = model.PetCount;
                    personal.Username   = model.Username;
                    personal.EMail      = model.EMail;
                    personal.Password   = model.Password;
                    personal.Phone      = model.Phone;
                    personal.Address    = model.Address;
                    personal.UserRoleID = 2;
                    personal.IsActive   = false;

                    if (fileUpload != null)
                    {
                        Image image  = Image.FromStream(fileUpload.InputStream);
                        int   width  = Convert.ToInt32(ConfigurationManager.AppSettings["ImageWidth"].ToString());
                        int   height = Convert.ToInt32(ConfigurationManager.AppSettings["ImageHeight"].ToString());

                        string name = "/Content/img" + Guid.NewGuid() + Path.GetExtension(fileUpload.FileName);

                        Bitmap bmp = new Bitmap(image, width, height);
                        bmp.Save(Server.MapPath(name));

                        model.Image = name;

                        personal.ImagePath1 = model.Image;
                    }
                    bool result = _personalService.Insert(personal);
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
            }
            return(View("Login"));
        }