Beispiel #1
0
        public static async Task <RentoImage> Select(int userId, int id)
        {
            RentoImage image = null;
            await DataBaseHelper.Instance.ExecuteReader(StoredProcedure.IMAGEDATA_SELECT,
                                                        delegate(SqlCommand cmd)
            {
                cmd.Parameters.AddWithValue("@Id", id);
                cmd.Parameters.AddWithValue("@UserId", userId);
            }, async delegate(SqlDataReader reader)
            {
                image = await GetRentoImage(reader);
            });

            return(image);
        }
Beispiel #2
0
        protected static async Task <RentoImage> GetRentoImage(SqlDataReader reader)
        {
            RentoImage image = null;

            if (await reader.ReadAsync())
            {
                image = new RentoImage()
                {
                    FileName = reader.GetString(1),
                    Content  = new byte[reader.GetInt32(2)]
                };
                reader.GetStream(0).Read(image.Content, 0, image.Content.Length);
            }
            return(image);
        }
Beispiel #3
0
        protected static async Task <List <RentoImage> > GetRentoImages(SqlDataReader reader)
        {
            List <RentoImage> images = null;

            do
            {
                var image = new RentoImage()
                {
                    FileName = reader.GetString(1),
                    Content  = new byte[reader.GetInt32(2)]
                };
                reader.GetStream(0).Read(image.Content, 0, image.Content.Length);
                images.Add(image);
            } while (await reader.ReadAsync());

            return(images);
        }
Beispiel #4
0
        public async Task <ActionResult> Save(UserInfo userInfo)
        {
            try
            {
                RentoImage logo        = null;
                RentoImage licence     = null;
                RentoImage refarmeCard = null;

                if (userInfo.LogoFile != null)
                {
                    logo = new Entity.RentoImage()
                    {
                        FileName = userInfo.LogoFile.FileName,
                        Content  = new byte[userInfo.LogoFile.ContentLength],
                    };
                    userInfo.LogoFile.InputStream.Read(logo.Content, 0, userInfo.LogoFile.ContentLength);
                    userInfo.LogoFile.InputStream.Dispose();
                }
                if (userInfo.LicenceFile != null)
                {
                    licence = new RentoImage()
                    {
                        FileName = userInfo.LicenceFile.FileName,
                        Content  = new byte[userInfo.LicenceFile.ContentLength],
                    };
                    userInfo.LicenceFile.InputStream.Read(licence.Content, 0, userInfo.LicenceFile.ContentLength);
                    userInfo.LicenceFile.InputStream.Dispose();
                }
                if (userInfo.RefarmeCardFile != null)
                {
                    refarmeCard = new Entity.RentoImage()
                    {
                        FileName = userInfo.RefarmeCardFile.FileName,
                        Content  = new byte[userInfo.RefarmeCardFile.ContentLength],
                    };
                    userInfo.RefarmeCardFile.InputStream.Read(refarmeCard.Content, 0, userInfo.RefarmeCardFile.ContentLength);
                    userInfo.RefarmeCardFile.InputStream.Dispose();
                }

                var saveResponse = await CallApi <Entity.User, Task>("User/UpdateUserInfo", new Entity.User()
                {
                    CityId            = userInfo.CityId,
                    CountryId         = userInfo.CountryId,
                    Id                = userInfo.Id,
                    Flag              = userInfo.Flag,
                    Longitude         = userInfo.Longitude,
                    Latitude          = userInfo.Latitude,
                    Mobile            = userInfo.Mobile,
                    Name              = userInfo.Name,
                    WorkingTimeDays   = userInfo.WorkingTimeDays,
                    WorkingTimeEnd    = userInfo.WorkingTimeEnd,
                    WorkingTimeStart  = userInfo.WorkingTimeStart,
                    Phone             = userInfo.Phone,
                    Logo              = logo,
                    TermsAndCondition = userInfo.TermsAndCondition,
                    Licence           = licence,
                    RefarmeCard       = refarmeCard,
                    OrganizationId    = userInfo.OrganizationId
                });

                return(RentoJson(saveResponse));
            }
            catch (Exception e)
            {
                Logger.Exception(e);
            }
            return(RentoJsonError());
        }