コード例 #1
0
        public ACRF_AdminDetailsModel GetAdminProfile(int id)
        {
            ACRF_AdminDetailsModel objModel = new ACRF_AdminDetailsModel();

            try
            {
                string sqlstr = "select Id, isnull(AdminName,'') as AdminName, isnull(Address,'') as Address, isnull(ContactName,'') as ContactName, "
                                + " isnull(Mobile,'') as Mobile, isnull(Email,'') as Email, isnull(FAX,'') as FAX, isnull(SkypeId,'') as SkypeId, "
                                + " isnull(MiscInfo,'') as MiscInfo, isnull(Password,'') as Password, isnull(CountryId,0) as CountryId, "
                                + " isnull(PostalCode,'') as PostalCode, isnull(CreatedBy,'') as CreatedBy, isnull(CreatedOn,'') as CreatedOn,  "
                                + " isnull(ProfilePicture,'') as ProfilePicture from ACRF_AdminDetails where Id=@Id";

                var connection = gConnection.Connection();
                connection.Open();
                SqlCommand cmd = new SqlCommand(sqlstr, connection);
                cmd.Parameters.AddWithValue("@Id", id);
                SqlDataReader sdr = cmd.ExecuteReader();
                while (sdr.Read())
                {
                    objModel.Id          = Convert.ToInt32(sdr["Id"].ToString());
                    objModel.AdminName   = sdr["AdminName"].ToString();
                    objModel.Address     = sdr["Address"].ToString();
                    objModel.ContactName = sdr["ContactName"].ToString();
                    objModel.Mobile      = sdr["Mobile"].ToString();
                    objModel.Email       = sdr["Email"].ToString();
                    objModel.FAX         = sdr["FAX"].ToString();
                    objModel.SkypeId     = sdr["SkypeId"].ToString();
                    objModel.MiscInfo    = sdr["MiscInfo"].ToString();
                    objModel.Password    = sdr["Password"].ToString();
                    objModel.CountryId   = Convert.ToInt32(sdr["CountryId"].ToString());
                    objModel.PostalCode  = sdr["PostalCode"].ToString();
                    objModel.CreatedBy   = sdr["CreatedBy"].ToString();
                    objModel.CreatedOn   = Convert.ToDateTime(sdr["CreatedOn"].ToString());
                    objModel.Password    = Encryption.decrypt(objModel.Password);
                    if (sdr["ProfilePicture"].ToString() == "")
                    {
                        objModel.ProfilePicture = "";
                    }
                    else
                    {
                        objModel.ProfilePicture = GlobalFunction.GetAPIUrl() + sdr["ProfilePicture"].ToString();
                    }
                }
                connection.Close();
            }
            catch (Exception ex)
            {
                ErrorHandlerClass.LogError(ex);
            }
            return(objModel);
        }
コード例 #2
0
        public IHttpActionResult ViewAdminProfile(int id)
        {
            ACRF_AdminDetailsModel objList = new ACRF_AdminDetailsModel();

            try
            {
                objList = objAuthVM.GetAdminProfile(id);
            }
            catch (Exception ex)
            {
                ErrorHandlerClass.LogError(ex);
            }

            return(Ok(new { results = objList }));
        }
コード例 #3
0
        public string UpdateAdminProfile(ACRF_AdminDetailsModel objModel)
        {
            string result = "Error! Profile not updated;";

            try
            {
                string sqlstr = " update ACRF_AdminDetails set AdminName=@AdminName,Address=@Address,ContactName=@ContactName,Mobile=@Mobile,"
                                + " Email=@Email,FAX=@FAX,SkypeId=@SkypeId,MiscInfo=@MiscInfo,Password=@Password,CountryId=@CountryId, "
                                + " PostalCode=@PostalCode,UpdatedBy=@UpdatedBy,UpdatedOn=@UpdatedOn where Id=@Id";

                var connection = gConnection.Connection();
                connection.Open();
                SqlCommand cmd = new SqlCommand(sqlstr, connection);
                cmd.Parameters.AddWithValue("@AdminName", objModel.AdminName);
                cmd.Parameters.AddWithValue("@Address", objModel.Address);
                cmd.Parameters.AddWithValue("@ContactName", objModel.ContactName);
                cmd.Parameters.AddWithValue("@Mobile", objModel.Mobile);
                cmd.Parameters.AddWithValue("@Email", objModel.Email);
                cmd.Parameters.AddWithValue("@FAX", objModel.FAX);
                cmd.Parameters.AddWithValue("@SkypeId", objModel.SkypeId);
                cmd.Parameters.AddWithValue("@MiscInfo", objModel.MiscInfo);
                cmd.Parameters.AddWithValue("@Password", Encryption.encrypt(objModel.Password));
                cmd.Parameters.AddWithValue("@CountryId", objModel.CountryId);
                cmd.Parameters.AddWithValue("@PostalCode", objModel.PostalCode);
                cmd.Parameters.AddWithValue("@UpdatedBy", objModel.UpdatedBy);
                cmd.Parameters.AddWithValue("@Id", objModel.Id);
                cmd.Parameters.AddWithValue("@UpdatedOn", StandardDateTime.GetDateTime());
                cmd.ExecuteNonQuery();
                connection.Close();


                result = "Profile Updated Successfully!";
            }
            catch (Exception ex)
            {
                ErrorHandlerClass.LogError(ex);
            }

            return(result);
        }
コード例 #4
0
        public IHttpActionResult UpdateAdminProfile(ACRF_AdminDetailsModel objModel)
        {
            string result = "";

            if (ModelState.IsValid)
            {
                try
                {
                    objModel.UpdatedBy = GlobalFunction.getLoggedInUser(Request.Headers.GetValues("Token").First());
                    result             = objAuthVM.UpdateAdminProfile(objModel);
                }
                catch (Exception ex)
                {
                    ErrorHandlerClass.LogError(ex);
                    result = ex.Message;
                }
            }
            else
            {
                result = "Enter Valid Mandatory Fields";
            }
            return(Ok(new { results = result }));
        }