Exemplo n.º 1
0
        public ResponseModel <ProfileViewModel> AddProfileDetail(ProfileViewModel model, string imagePath, string signPath)
        {
            ResponseModel <ProfileViewModel> response = new ResponseModel <ProfileViewModel> {
                Data = new ProfileViewModel()
            };

            try
            {
                ProfileInfo info      = new ProfileInfo();
                string      photoName = null;
                string      signName  = null;
                info.CreatedOn = DateTime.Now;
                info.IsActive  = true;
                info.CheckInId = model.CheckInId;
                if (!string.IsNullOrEmpty(model.Photo))
                {
                    photoName = Guid.NewGuid().ToString() + "." + Convert.ToString(ImageFormat.Jpeg);
                    var    path        = Path.Combine(imagePath, photoName.ToString());
                    string image64Base = model.Photo.Replace("\r", "").Replace("\n", "");
                    byte[] imageBytes  = Convert.FromBase64String(image64Base);
                    File.WriteAllBytes(path, imageBytes);
                }
                info.Photo = photoName;
                if (!string.IsNullOrEmpty(model.Signature))
                {
                    signName = Guid.NewGuid().ToString() + "." + Convert.ToString(ImageFormat.Png);
                    var    _signPath   = Path.Combine(signPath, signName.ToString());
                    string sign64Base  = model.Signature.Replace("\r", "").Replace("\n", "");
                    byte[] _imageBytes = Convert.FromBase64String(sign64Base);
                    File.WriteAllBytes(_signPath, _imageBytes);
                }
                info.Signature = signName;

                acmContext.ProfileInfo.Add(info);
                acmContext.SaveChanges();
                ProfileViewModel _profile = new ProfileViewModel();
                _profile.CheckInId = info.CheckInId;
                _profile.CreatedOn = info.CreatedOn;
                _profile.IsActive  = info.IsActive;
                _profile.Photo     = info.Photo;
                _profile.Signature = info.Signature;
                response.Data      = _profile;
                response.Status    = true;
                response.Message   = "success";
            }
            catch (Exception ex)
            {
                response.Status  = false;
                response.Message = ex.Message;
            }
            return(response);
        }
Exemplo n.º 2
0
        public ResponseModel <string> AddPhotoComment(PhotoCommentModel model)
        {
            ResponseModel <string> response = new ResponseModel <string> {
                Data = ""
            };

            try
            {
                PhotoComment _comment = new PhotoComment();
                _comment.PhotoId   = model.PhotoId;
                _comment.IsActive  = true;
                _comment.CreatedOn = DateTime.Now;
                _comment.Comment   = model.Comment;
                acmContext.PhotoComment.Add(_comment);
                acmContext.SaveChanges();
                response.Status  = true;
                response.Message = "success";
            }
            catch (Exception ex)
            {
                response.Status  = false;
                response.Message = ex.Message;
            }
            return(response);
        }
Exemplo n.º 3
0
        public ResponseModel <string> AddGalleryImage(GalleryViewModel model, string serverPath, string thumbPath)
        {
            ResponseModel <string> response = new ResponseModel <string> {
                Data = ""
            };

            try
            {
                Gallery gallery = new Gallery();
                gallery.CreatedOn = DateTime.Now;
                gallery.IsActive  = true;
                gallery.IsMain    = false;
                gallery.StoreId   = model.StoreId;

                string FileName    = Guid.NewGuid().ToString() + "." + Convert.ToString(model.FileName.Split('.')[1]);
                var    path        = Path.Combine(serverPath, FileName.ToString());
                string image64Base = model.Image.Replace("\r", "").Replace("\n", "");
                byte[] imageBytes  = Convert.FromBase64String(image64Base);
                File.WriteAllBytes(path, imageBytes);

                gallery.Image = FileName;
                using (MemoryStream ms = new MemoryStream(imageBytes))
                {
                    // string thumbName = Guid.NewGuid().ToString() + "." + Convert.ToString(ImageFormat.Png);
                    var outpath = Path.Combine(thumbPath, FileName.ToString());
                    ImageUtility.Thumbnail(path, outpath);
                    gallery.ThumbnailImage = FileName;
                }
                gallery.CheckInId = model.CheckInId;
                acmContext.Gallery.Add(gallery);
                acmContext.SaveChanges();
                response.Status  = true;
                response.Message = "success";
            }
            catch (Exception ex)
            {
                response.Status  = false;
                response.Message = ex.Message;
            }
            return(response);
        }
Exemplo n.º 4
0
        public ResponseModel <StoreInfoViewModel> SaveStoreLogo(StoreInfoViewModel _model)
        {
            ResponseModel <StoreInfoViewModel> response = new ResponseModel <StoreInfoViewModel>();

            try
            {
                var model = acmContext.StoreInfo.Where(e => e.StoreId == _model.StoreId).FirstOrDefault();
                if (model != null)
                {
                    model.Logo = _model.LogoName;
                    // model.LogoId = _model.LogoId;
                    model.StoreId = _model.StoreId;

                    acmContext.SaveChanges();

                    // response.Data = list;
                    response.Status  = true;
                    response.Message = "success";
                }
                else
                {
                    StoreInfo storeModel = new StoreInfo();
                    storeModel.Logo = _model.LogoName;
                    //storeModel.LogoId = model.LogoId;
                    storeModel.StoreId = _model.StoreId;
                    acmContext.Add(storeModel);
                    acmContext.SaveChanges();
                    response.Data    = null;
                    response.Message = "success";
                    response.Status  = true;
                }
            }
            catch (Exception ex)
            {
                response.Data    = null;
                response.Status  = false;
                response.Message = ex.Message;
            }

            return(response);
        }