コード例 #1
0
 public int Delete(int flag, RegistrationViewModel objEntity)
 {
     int result = 0;
     try
     {
         Database objDB = base.GetDatabase();
         // Create a suitable command type and add the required parameter.
         using (DbCommand sprocCmd = objDB.GetStoredProcCommand(SP_RegistrationViewModelDelete))
         {
             objDB.AddInParameter(sprocCmd, PARAM_Flag, DbType.Int32, flag);
             objDB.AddInParameter(sprocCmd, PARAM_RegistrationId, DbType.Int32, objEntity.RegistrationId);
             objDB.AddOutParameter(sprocCmd, PARAM_Result, DbType.Int32, result);
             objDB.ExecuteNonQuery(sprocCmd);
             result = Convert.ToInt32(objDB.GetParameterValue(sprocCmd, PARAM_Result));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
     }
     return result;
 }
コード例 #2
0
        public ActionResult Create(RegistrationViewModel objEntity)
        {
            RegistrationRepository objRegistrationRepository = new RegistrationRepository();

            if (ModelState.IsValid)
            {

                objEntity.Status = StatusFlags.Active.GetHashCode();
                objEntity.UserTypeId = UserTypes.User.GetHashCode();

                objRegistrationRepository.Insert(objEntity);

                if (objEntity.Result == ResultFlags.Success.GetHashCode())
                {
                    this.Flash("success", "Registration created successfully ");

                    //return RedirectToAction("Index");
                    return RedirectToAction("Login", "User");

                }
                else if (objEntity.Result == ResultFlags.Failure.GetHashCode())
                {
                    this.Flash("error", "Failed to create account");

                    return RedirectToAction("Index");
                }
                else if (objEntity.Result == ResultFlags.Duplicate.GetHashCode())
                {
                    this.Flash("warning", "It already exist");

                }
            }

            return View(objEntity);
        }
コード例 #3
0
        // GET: /Registration/
        public ActionResult Create()
        {
            var objEntity = new RegistrationViewModel();

            objEntity.DateOfBirth = DateTime.Now;
            return View(objEntity);
        }
コード例 #4
0
        public RegistrationViewModel Insert(RegistrationViewModel objEntity)
        {
            try
            {
                Database objDB = base.GetDatabase();

                using (DbCommand sprocCmd = objDB.GetStoredProcCommand(SP_RegistrationViewModelInsert))
                {
                    objDB.AddInParameter(sprocCmd, PARAM_USERID, DbType.Int32, objEntity.UserId);
                    objDB.AddInParameter(sprocCmd, PARAM_ROLEID, DbType.Int32, objEntity.RoleId);
                    objDB.AddInParameter(sprocCmd, PARAM_FIRSTNAME, DbType.String, objEntity.FirstName);
                    objDB.AddInParameter(sprocCmd, PARAM_LASTNAME, DbType.String, objEntity.LastName);
                    objDB.AddInParameter(sprocCmd, PARAM_PHOTONAME, DbType.String, objEntity.PhotoName);

                    objDB.AddInParameter(sprocCmd, PARAM_DATEOFBIRTH, DbType.DateTime, objEntity.DateOfBirth);
                    objDB.AddInParameter(sprocCmd, PARAM_GENDER, DbType.Int32, objEntity.Gender.GetHashCode());

                    objDB.AddInParameter(sprocCmd, PARAM_COUNTRYID, DbType.Int32, objEntity.CountryId);
                    objDB.AddInParameter(sprocCmd, PARAM_STATEID, DbType.Int32, objEntity.StateId);

                    objDB.AddInParameter(sprocCmd, PARAM_LOCATION, DbType.String, objEntity.Location);
                    objDB.AddInParameter(sprocCmd, PARAM_EMAIL, DbType.String, objEntity.UserEmail);
                    objDB.AddInParameter(sprocCmd, PARAM_PASSWORD, DbType.String, objEntity.Password);

                    objDB.AddInParameter(sprocCmd, PARAM_PASSWORDSALT, DbType.String, objEntity.PasswordSalt);

                    objDB.AddInParameter(sprocCmd, PARAM_MOBILENUMBER, DbType.String, objEntity.MobileNumber);
                    objDB.AddInParameter(sprocCmd, PARAM_STATUS, DbType.Int32, objEntity.Status);

                    objDB.AddOutParameter(sprocCmd, PARAM_REGISTRATIONID, DbType.Int32, objEntity.RegistrationId);
                    objDB.AddOutParameter(sprocCmd, PARAM_RESULT, DbType.Int32, objEntity.Result);

                    objDB.ExecuteNonQuery(sprocCmd);

                    objEntity.RegistrationId = Convert.ToInt32(objDB.GetParameterValue(sprocCmd, PARAM_REGISTRATIONID));
                    objEntity.Result = Convert.ToInt32(objDB.GetParameterValue(sprocCmd, PARAM_RESULT));

                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return objEntity;
        }
コード例 #5
0
        public RegistrationViewModel Insert(RegistrationViewModel objEntity)
        {
            try
            {
                Database objDB = base.GetDatabase();

                using (DbCommand sprocCmd = objDB.GetStoredProcCommand(SP_RegistrationViewModelInsert))
                {
                    objDB.AddInParameter(sprocCmd, PARAM_UserId, DbType.Int32, objEntity.UserId);
                    objDB.AddInParameter(sprocCmd, PARAM_UserTypeID, DbType.Int32, objEntity.UserTypeId);
                    objDB.AddInParameter(sprocCmd, PARAM_Name, DbType.String, objEntity.Name);

                    objDB.AddInParameter(sprocCmd, PARAM_DateOfBirth, DbType.DateTime, objEntity.DateOfBirth);
                    objDB.AddInParameter(sprocCmd, PARAM_Gender, DbType.Int32, objEntity.Gender.GetHashCode());

                    objDB.AddInParameter(sprocCmd, PARAM_City, DbType.String, objEntity.City);
                    objDB.AddInParameter(sprocCmd, PARAM_Email, DbType.String, objEntity.UserEmail);
                    objDB.AddInParameter(sprocCmd, PARAM_Password, DbType.String, objEntity.Password);
                    objDB.AddInParameter(sprocCmd, PARAM_MobileNumber, DbType.String, objEntity.MobileNumber);
                    objDB.AddInParameter(sprocCmd, PARAM_Status, DbType.Int32, objEntity.Status);

                    objDB.AddOutParameter(sprocCmd, PARAM_RegistrationId, DbType.Int32, objEntity.RegistrationId);
                    objDB.AddOutParameter(sprocCmd, PARAM_Result, DbType.Int32, objEntity.Result);

                    objDB.ExecuteNonQuery(sprocCmd);

                    objEntity.RegistrationId = Convert.ToInt32(objDB.GetParameterValue(sprocCmd, PARAM_RegistrationId));
                    objEntity.Result = Convert.ToInt32(objDB.GetParameterValue(sprocCmd, PARAM_Result));

                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return objEntity;
        }
コード例 #6
0
        public RegistrationViewModel Update(int flag, RegistrationViewModel objEntity)
        {
            try
            {
                //
                Database objDB = base.GetDatabase();
                // Create a suitable command type and add the required parameter.
                using (DbCommand sprocCmd = objDB.GetStoredProcCommand(SP_RegistrationViewModelUpdate))
                {
                    objDB.AddInParameter(sprocCmd, PARAM_Flag, DbType.Int32, flag);
                    objDB.AddInParameter(sprocCmd, PARAM_RegistrationId, DbType.Int32, objEntity.RegistrationId);

                    objDB.AddInParameter(sprocCmd, PARAM_UserId, DbType.Int32, objEntity.UserId);
                    objDB.AddInParameter(sprocCmd, PARAM_Name, DbType.String, objEntity.Name);

                    objDB.AddInParameter(sprocCmd, PARAM_DateOfBirth, DbType.String, objEntity.DateOfBirth);
                    objDB.AddInParameter(sprocCmd, PARAM_Gender, DbType.Int32, objEntity.Gender);

                    objDB.AddInParameter(sprocCmd, PARAM_City, DbType.String, objEntity.City);
                    objDB.AddInParameter(sprocCmd, PARAM_MobileNumber, DbType.String, objEntity.MobileNumber);

                    objDB.AddOutParameter(sprocCmd, PARAM_Result, DbType.Int32, objEntity.Result);

                    objDB.ExecuteNonQuery(sprocCmd);
                    objEntity.Result = Convert.ToInt32(objDB.GetParameterValue(sprocCmd, PARAM_Result));
                }
                //
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
            return objEntity;
        }
コード例 #7
0
        public List<RegistrationViewModel> Select(int flag, RegistrationViewModel objEntity)
        {
            var objEntityList = new List<RegistrationViewModel>();
            try
            {
                Database objDB = base.GetDatabase();
                // Create a suitable command type and add the required parameter.
                using (DbCommand sprocCmd = objDB.GetStoredProcCommand(SP_RegistrationViewModelSelect))
                {
                    objDB.AddInParameter(sprocCmd, PARAM_Flag, DbType.Int32, flag);
                    objDB.AddInParameter(sprocCmd, PARAM_RegistrationId, DbType.Int32, objEntity.RegistrationId);
                    using (IDataReader reader = objDB.ExecuteReader(sprocCmd))
                    {
                        while (reader.Read())
                        {
                            var objEntityViewModel = new RegistrationViewModel();

                            objEntityViewModel.RegistrationId = reader.GetInt32(reader.GetOrdinal(PARAM_RegistrationId));
                                 //  objEntityViewModel.UserId = reader.GetInt32(reader.GetOrdinal(PARAM_UserId));
                                   objEntityViewModel.UserId = reader.IsDBNull(reader.GetOrdinal(PARAM_UserId)) ? 0: reader.GetInt32(reader.GetOrdinal(PARAM_UserId));
                                    objEntityViewModel.UserTypeId = reader.GetInt32(reader.GetOrdinal(PARAM_UserTypeID));
                                    objEntityViewModel.Name = reader.GetString(reader.GetOrdinal(PARAM_Name));

                                    objEntityViewModel.DateOfBirth = reader.GetDateTime(reader.GetOrdinal(PARAM_DateOfBirth));
                                    objEntityViewModel.Gender = (GenderEnum)reader.GetInt32(reader.GetOrdinal(PARAM_Gender));

                                    objEntityViewModel.City = reader.IsDBNull(reader.GetOrdinal(PARAM_City)) ? string.Empty : reader.GetString(reader.GetOrdinal(PARAM_City));

                                    objEntityViewModel.MobileNumber = reader.GetString(reader.GetOrdinal(PARAM_MobileNumber));
                                    objEntityViewModel.UserEmail = reader.GetString(reader.GetOrdinal(PARAM_Email));

                            if (objEntityViewModel != null)
                            {
                                objEntityList.Add(objEntityViewModel);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
            return objEntityList;
        }
コード例 #8
0
        public ActionResult ProfileEdit(int id, RegistrationUpdateViewModel objUpdateEntity)
        {
            var objRegistrationRepository = new RegistrationRepository();
            string fileName = string.Empty;
            string oldFileName = string.Empty;

            if (ModelState.IsValid)
            {
                #region FileUpload

                if (objUpdateEntity.UploadPhoto != null)
                {
                    fileName = Guid.NewGuid().ToString() + Path.GetExtension(objUpdateEntity.UploadPhoto.FileName);
                    oldFileName = objUpdateEntity.PhotoName;
                    objUpdateEntity.PhotoName = fileName;
                }

                #endregion
                objUpdateEntity.FirstName = objUpdateEntity.FirstName.Trim();
                objUpdateEntity.LastName = objUpdateEntity.LastName.Trim();
                objUpdateEntity.PhotoName = objUpdateEntity.PhotoName;
                objUpdateEntity.DateOfBirth = objUpdateEntity.DateOfBirth;
                objUpdateEntity.Location = objUpdateEntity.Location.Trim();
                objUpdateEntity.MobileNumber = objUpdateEntity.MobileNumber.Trim();
                objUpdateEntity.RegistrationId = id;

                var objEntity = new RegistrationViewModel()
                {
                    RegistrationId = objUpdateEntity.RegistrationId,
                    UserId = objUpdateEntity.UserId,
                    FirstName = objUpdateEntity.FirstName,
                    LastName = objUpdateEntity.LastName,
                    PhotoName = objUpdateEntity.PhotoName,

                    DateOfBirth = objUpdateEntity.DateOfBirth,
                    Gender = objUpdateEntity.Gender,

                    Location = objUpdateEntity.Location,
                    MobileNumber = objUpdateEntity.MobileNumber
                };

                objEntity = objRegistrationRepository.Update(RegistrationFlags.UpdateByID.GetHashCode(), objEntity);

                if (objEntity.Result == ResultFlags.Success.GetHashCode())
                {
                    #region FileUpload
                    //delete old file

                    //file name
                    if (objUpdateEntity.UploadPhoto != null)
                    {
                        if (!string.IsNullOrEmpty(objUpdateEntity.UploadPhoto.FileName))
                        {
                            ApplicationHelpers.DeleteFile(Path.Combine(Server.MapPath(ApplicationConstant.UPLOADED_USER_PHOTO_PATH), oldFileName));
                        }
                        string path = Path.Combine(Server.MapPath(ApplicationConstant.UPLOADED_USER_PHOTO_PATH), fileName);
                        // WebImage.Save()
                        objUpdateEntity.UploadPhoto.SaveAs(path);
                    }

                    #endregion

                    this.Flash("Success", "My Profile updated successfully ");

                    //reload admin profile
                    SessionWrapper.UserAccount = null;
                    AccountRepository objAccountRepository = new AccountRepository();
                    objAccountRepository.SetAccountByUser(objEntity.UserId);

                    return RedirectToAction("Dashboard", "Admin");
                }
                else if (objEntity.Result == ResultFlags.Failure.GetHashCode())
                {
                    this.Flash("Error", "My Profile failed to update");

                }
                else if (objEntity.Result == ResultFlags.Duplicate.GetHashCode())
                {
                    this.Flash("Warning", "It already exist");

                }
            }

            return View(objUpdateEntity);
        }
コード例 #9
0
        public ActionResult ProfileEdit(int id)
        {
            var objRegistrationRepository = new RegistrationRepository();

            var objEntity = new RegistrationViewModel();

            var objUpdateEntity = new RegistrationUpdateViewModel();

            objEntity = objRegistrationRepository.Select(RegistrationFlags.SelectByID.GetHashCode(), new RegistrationViewModel()
            {
                RegistrationId = id
            }).FirstOrDefault();
            if (objEntity == null)
            {
                this.Flash("error", "Failed to edit profile details");

                return RedirectToAction("Dashboard");
            }

            objUpdateEntity.RegistrationId = objEntity.RegistrationId;
            objUpdateEntity.UserId = objEntity.UserId;
            objUpdateEntity.FirstName = objEntity.FirstName;
            objUpdateEntity.LastName = objEntity.LastName;
            objUpdateEntity.PhotoName = objEntity.PhotoName;

            objUpdateEntity.DateOfBirth = objEntity.DateOfBirth;
            objUpdateEntity.Gender = objEntity.Gender;

            objUpdateEntity.Location = objEntity.Location;
            objUpdateEntity.MobileNumber = objEntity.MobileNumber;

            return View(objUpdateEntity);
        }
コード例 #10
0
        public ActionResult Register(RegistrationViewModel objEntity)
        {
            RegistrationRepository objRegistrationRepository = new RegistrationRepository();
            string fileName = string.Empty;

            if (ModelState.IsValid)
            {
                #region FileUpload

                if (objEntity.UploadPhoto != null)
                {
                    fileName = Guid.NewGuid().ToString() + Path.GetExtension(objEntity.UploadPhoto.FileName);
                    objEntity.PhotoName = fileName;

                }
                else
                {
                    objEntity.PhotoName = string.Empty;
                }

                #endregion

                objEntity.RoleId = (Int16)RoleUserDefinedEnum.User.GetHashCode();

                PasswordHelpers.HashedPassword objHashedPassword = PasswordHelpers.Generate(objEntity.Password);

                objEntity.Password = objHashedPassword.Password;

                objEntity.PasswordSalt = objHashedPassword.Salt;

                objEntity.Status = StatusEnum.Active.GetHashCode();

                objRegistrationRepository.Insert(objEntity);

                if (objEntity.Result == ResultFlags.Success.GetHashCode())
                {
                    this.Flash("success", "Registration created successfully ");

                    #region FileUpload

                    //file name
                    if (objEntity.PhotoName != null)
                    {
                        string path = Path.Combine(Server.MapPath(ApplicationConstant.UPLOADED_USER_PHOTO_PATH), fileName);
                        // WebImage.Save()
                        objEntity.UploadPhoto.SaveAs(path);
                    }

                    #endregion
                    //return RedirectToAction("Index");
                    return RedirectToAction("Login", "User");

                }
                else if (objEntity.Result == ResultFlags.Failure.GetHashCode())
                {
                    this.Flash("Error", "Failed to create account");

                    return RedirectToAction("Index");
                }
                else if (objEntity.Result == ResultFlags.Duplicate.GetHashCode())
                {
                    this.Flash("Warning", "It already exist");

                }
            }

            return View(objEntity);
        }
コード例 #11
0
        public RegistrationViewModel Update(int flag, RegistrationViewModel objEntity)
        {
            try
            {
                //
                Database objDB = base.GetDatabase();
                // Create a suitable command type and add the required parameter.
                using (DbCommand sprocCmd = objDB.GetStoredProcCommand(SP_RegistrationViewModelUpdate))
                {
                    objDB.AddInParameter(sprocCmd, PARAM_FLAG, DbType.Int32, flag);
                    objDB.AddInParameter(sprocCmd, PARAM_REGISTRATIONID, DbType.Int32, objEntity.RegistrationId);

                    objDB.AddInParameter(sprocCmd, PARAM_USERID, DbType.Int32, objEntity.UserId);
                    objDB.AddInParameter(sprocCmd, PARAM_FIRSTNAME, DbType.String, objEntity.FirstName);
                    objDB.AddInParameter(sprocCmd, PARAM_LASTNAME, DbType.String, objEntity.LastName);
                    objDB.AddInParameter(sprocCmd, PARAM_PHOTONAME, DbType.String, objEntity.PhotoName);

                    objDB.AddInParameter(sprocCmd, PARAM_DATEOFBIRTH, DbType.String, objEntity.DateOfBirth);
                    objDB.AddInParameter(sprocCmd, PARAM_GENDER, DbType.Int32, objEntity.Gender);

                    objDB.AddInParameter(sprocCmd, PARAM_COUNTRYID, DbType.Int32, objEntity.CountryId);
                    objDB.AddInParameter(sprocCmd, PARAM_STATEID, DbType.Int32, objEntity.StateId);

                    objDB.AddInParameter(sprocCmd, PARAM_LOCATION, DbType.String, objEntity.Location);
                    objDB.AddInParameter(sprocCmd, PARAM_MOBILENUMBER, DbType.String, objEntity.MobileNumber);

                    objDB.AddOutParameter(sprocCmd, PARAM_RESULT, DbType.Int32, objEntity.Result);

                    objDB.ExecuteNonQuery(sprocCmd);
                    objEntity.Result = Convert.ToInt32(objDB.GetParameterValue(sprocCmd, PARAM_RESULT));
                }
                //
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
            return objEntity;
        }
コード例 #12
0
        public List<RegistrationViewModel> Select(int flag, RegistrationViewModel objEntity)
        {
            var objEntityList = new List<RegistrationViewModel>();
            try
            {
                Database objDB = base.GetDatabase();
                // Create a suitable command type and add the required parameter.
                using (DbCommand sprocCmd = objDB.GetStoredProcCommand(SP_RegistrationViewModelSelect))
                {
                    objDB.AddInParameter(sprocCmd, PARAM_FLAG, DbType.Int32, flag);
                    objDB.AddInParameter(sprocCmd, PARAM_REGISTRATIONID, DbType.Int32, objEntity.RegistrationId);
                    using (IDataReader reader = objDB.ExecuteReader(sprocCmd))
                    {
                        while (reader.Read())
                        {
                            var objEntityViewModel = new RegistrationViewModel();

                            objEntityViewModel.RegistrationId = reader.GetColumnValue<int>(PARAM_REGISTRATIONID);

                            objEntityViewModel.UserId = reader.GetColumnValue<int>(PARAM_USERID);

                            //objEntityViewModel.PasswordSalt = reader.GetColumnValue<String>(PARAM_PASSWORDSALT);

                            objEntityViewModel.RoleId = reader.GetColumnValue<Int16>(PARAM_ROLEID);

                            objEntityViewModel.FirstName = reader.GetColumnValue<String>(PARAM_FIRSTNAME);
                            objEntityViewModel.LastName = reader.GetColumnValue<String>(PARAM_LASTNAME);
                            objEntityViewModel.PhotoName = reader.GetColumnValue<String>(PARAM_PHOTONAME);

                            objEntityViewModel.DateOfBirth = reader.GetColumnValue<DateTime>(PARAM_DATEOFBIRTH);

                            objEntityViewModel.Gender = (GenderEnum)reader.GetColumnValue<Int16>(PARAM_GENDER);

                            objEntityViewModel.CountryId = reader.GetColumnValue<Int32>(PARAM_COUNTRYID);
                            objEntityViewModel.StateId = reader.GetColumnValue<Int32>(PARAM_STATEID);

                            objEntityViewModel.Location = reader.GetColumnValue<String>(PARAM_LOCATION);

                            objEntityViewModel.MobileNumber = reader.GetColumnValue<String>(PARAM_MOBILENUMBER);

                            //objEntityViewModel.UserEmail = reader.GetColumnValue<String>(PARAM_EMAIL);

                            if (objEntityViewModel != null)
                            {
                                objEntityList.Add(objEntityViewModel);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
            return objEntityList;
        }
コード例 #13
0
        public ActionResult Edit(int id, RegistrationUpdateViewModel objUpdateEntity)
        {
            var objRegistrationRepository = new RegistrationRepository();

            if (ModelState.IsValid)
            {

                objUpdateEntity.Name = objUpdateEntity.Name.Trim();

                objUpdateEntity.City = objUpdateEntity.City.Trim();
                objUpdateEntity.MobileNumber = objUpdateEntity.MobileNumber.Trim();
                objUpdateEntity.RegistrationId = id;

             var objEntity=   new RegistrationViewModel()
                    {
                        RegistrationId = objUpdateEntity.RegistrationId,
                        UserId = objUpdateEntity.UserId,
                        Name = objUpdateEntity.Name,

                        DateOfBirth = objUpdateEntity.DateOfBirth,
                        Gender = objUpdateEntity.Gender,

                        City = objUpdateEntity.City,
                        MobileNumber = objUpdateEntity.MobileNumber
                    };

             objEntity = objRegistrationRepository.Update(RegistrationFlags.UpdateByID.GetHashCode(), objEntity);

             if (objEntity.Result == ResultFlags.Success.GetHashCode())
                {
                    this.Flash("success", "Data updated successfully ");

                    return RedirectToAction("Index");
                }
             else if (objEntity.Result == ResultFlags.Failure.GetHashCode())
                {
                    this.Flash("error", "Account failed to update");

                }
             else if (objEntity.Result == ResultFlags.Duplicate.GetHashCode())
                {
                    this.Flash("warning", "It already exist");

                }
            }

            return View(objUpdateEntity);
        }