public async Task <ActionResult> Login(LoginViewModel lvm)
        {
            var sb = new StringBuilder();
            var fa = FirebaseConnection.FirebaseAuthentication();

            try
            {
                var userAuth = await fa.SignInWithEmailAndPasswordAsync(lvm.userName, lvm.password);

                var firebase    = FirebaseConnection.FirebaseDatabase();
                var userDetails = await firebase.Child("adminUserRegistration").Child(userAuth.User.LocalId).OnceAsync <GetRegistrationViewModel>();

                foreach (var ud in userDetails)
                {
                    SetSession.SetUserSession(userAuth.User.LocalId, ud.Object.designation, sb.Append(ud.Object.firstName).Append(" ").Append(ud.Object.lastName).ToString());
                }
                return(RedirectToAction("Index", "Admin"));
            }
            catch (Exception userAuthException)
            {
                var userError = userAuthException.GetType().GetProperty("Reason").GetValue(userAuthException, null);
                ModelState.AddModelError("error", userError.ToString());
                return(View());
            }
        }
        public async Task <ActionResult> Registration(CreateRegistrationViewModel crvm, HttpPostedFileBase uploadProfile)
        {
            //createRegistrationViewModel crvm_ = new createRegistrationViewModel();
            var data = "Registration Failed !";

            try
            {
                var fa = FirebaseConnection.FirebaseAuthentication();
                var userVerification = await fa.CreateUserWithEmailAndPasswordAsync(crvm.emailId, crvm.password, crvm.firstName + " " + crvm.lastName, true);

                //if (crvm.uploadProfile != null)
                //{
                //    crvm.uploadProfile.SaveAs(Path.Combine(Server.MapPath("/images/"), crvm.uploadProfile.FileName));
                //}
                if (uploadProfile != null)
                {
                    var profileImage = FirebaseConnection.FirebaseStorageConnection();
                    var imagePath    = await profileImage.Child("Registration").Child(uploadProfile.FileName).PutAsync(uploadProfile.InputStream);

                    crvm.uploadProfile = imagePath;
                }
                var firebase    = FirebaseConnection.FirebaseDatabase();
                var regComplete = await firebase.Child("adminUserRegistration").Child(userVerification.User.LocalId).PostAsync(crvm, true);

                data = "Registration Successfully !";
            }
            catch (Exception userAuthException)
            {
                var userError = userAuthException.GetType().GetProperty("Reason").GetValue(userAuthException, null);
                ModelState.AddModelError("error", userError.ToString());
                return(View());
            }
            return(RedirectToAction("Login", "Admin", new { Status = data }));
        }
        public async Task <JsonResult> LoadCategory(string superCategoryKey)
        {
            var data         = "Category Load Failed !";
            var status       = false;
            var categoryList = (dynamic)null;

            try
            {
                var firebase = FirebaseConnection.FirebaseDatabase();
                switch (superCategoryKey)
                {
                case null:
                    categoryList = await firebase.Child("categoryFetch").OnceAsync <GetCategoryViewModel>();

                    break;

                default:
                    categoryList = await firebase.Child("category").Child(superCategoryKey).OnceAsync <GetCategoryViewModel>();

                    break;
                }
                data   = "Category Loaded Successfully !";
                status = true;
            }
            catch (Exception categoryLoadException)
            {
                var categoryError = categoryLoadException.GetType().GetProperty("Reason").GetValue(categoryLoadException, null);
            }
            return(Json(new { data = data, status = status, category = categoryList }, JsonRequestBehavior.AllowGet));
        }
 void GotSettings(Dictionary <string, object> settings, int group)
 {
     // apply settings to your game, eg:
     // SettingsManager.maxParticles = settings['max_particles']
     Debug.Log("got new settings");
     FirebaseConnection.GetInstance().PushGetSettings();
 }
示例#5
0
 public FetchedJob(FirebaseStorage storage, string queue, string jobId, string reference)
 {
     connection = (FirebaseConnection)storage.GetConnection();
     JobId      = jobId;
     Queue      = queue;
     Reference  = reference;
 }
        public async Task <JsonResult> AddSubcategory(CreateSubcategoryViewModel csvm)
        {
            var data   = "Subcategory Added Failed !";
            var status = false;

            try
            {
                var firebase     = FirebaseConnection.FirebaseDatabase();
                var categoryList = await firebase.Child("subCategory").Child(csvm.category).OnceAsync <GetSubcategoryViewModel>();

                foreach (var categoryDetail in categoryList)
                {
                    if (categoryDetail.Object.subCategoryName.Equals(csvm.subCategoryName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        data = "Subcategory Name Already Exist !";
                        return(Json(new { data = data, status = status }, JsonRequestBehavior.AllowGet));
                    }
                }
                csvm.subCategoryName = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(csvm.subCategoryName.ToLower().Trim());
                var subCategoryAdded = await firebase.Child("subCategory").Child(csvm.category).PostAsync(csvm, true);

                data   = "Subcategory Added Successfully !";
                status = true;
            }
            catch (Exception subCategoryAddException)
            {
                var subCatgeoryError = subCategoryAddException.GetType().GetProperty("Reason").GetValue(subCategoryAddException, null);
            }
            return(Json(new { data = data, status = status }, JsonRequestBehavior.AllowGet));
        }
        public async Task <JsonResult> AddProductSize(CreateProductVarientViewModel cpvvm)
        {
            var data   = "Product Size Added Failed !";
            var status = false;

            try
            {
                var firebase = FirebaseConnection.FirebaseDatabase();
                var sizeList = await firebase.Child("size").OnceAsync <GetProductVarientViewModel>();

                foreach (var sizeDetail in sizeList)
                {
                    if (sizeDetail.Object.sizeName.Equals(cpvvm.sizeName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        data = "Product Size Name Already Exist !";
                        return(Json(new { data = data, status = status }, JsonRequestBehavior.AllowGet));
                    }
                }
                cpvvm.sizeName = cpvvm.sizeName.ToUpper().Trim();
                var sizeAdded = await firebase.Child("size").PostAsync(cpvvm, true);

                data   = "Product Size Added Successfully !";
                status = true;
            }
            catch (Exception sizeAddException)
            {
                var sizeError = sizeAddException.GetType().GetProperty("Reason").GetValue(sizeAddException, null);
            }
            return(Json(new { data = data, status = status }, JsonRequestBehavior.AllowGet));
        }
示例#8
0
        public async Task <ActionResult> AddProduct(CreateProductViewModel cpvm, ProductImageViewModel pivm)
        {
            var data = "Product Added Failed !";

            try
            {
                var firebase     = FirebaseConnection.FirebaseDatabase();
                var productImage = FirebaseConnection.FirebaseStorageConnection();
                var imageName    = new StringBuilder();
                if (pivm.imageUploadFirst != null)
                {
                    imageName.Append(DateTime.Now.ToString("dd_MM_yyyy_hhmmss")).Append(Path.GetExtension(pivm.imageUploadFirst.FileName));
                    var imagePath = await productImage.Child("Product").Child(imageName.ToString()).PutAsync(pivm.imageUploadFirst.InputStream);

                    cpvm.imageUploadFirst     = imagePath;
                    cpvm.imageUploadFirstName = imageName.ToString();
                }
                if (pivm.imageUploadSecond != null)
                {
                    imageName = new StringBuilder();
                    imageName.Append(DateTime.Now.ToString("dd_MM_yyyy_hhmmss")).Append(Path.GetExtension(pivm.imageUploadSecond.FileName));
                    var imagePath = await productImage.Child("Product").Child(imageName.ToString()).PutAsync(pivm.imageUploadSecond.InputStream);

                    cpvm.imageUploadSecond     = imagePath;
                    cpvm.imageUploadSecondName = imageName.ToString();
                }
                if (pivm.imageUploadThird != null)
                {
                    imageName = new StringBuilder();
                    imageName.Append(DateTime.Now.ToString("dd_MM_yyyy_hhmmss")).Append(Path.GetExtension(pivm.imageUploadThird.FileName));
                    var imagePath = await productImage.Child("Product").Child(imageName.ToString()).PutAsync(pivm.imageUploadThird.InputStream);

                    cpvm.imageUploadThird     = imagePath;
                    cpvm.imageUploadThirdName = imageName.ToString();
                }
                if (pivm.imageUploadFourth != null)
                {
                    imageName = new StringBuilder();
                    imageName.Append(DateTime.Now.ToString("dd_MM_yyyy_hhmmss")).Append(Path.GetExtension(pivm.imageUploadFourth.FileName));
                    var imagePath = await productImage.Child("Product").Child(imageName.ToString()).PutAsync(pivm.imageUploadFourth.InputStream);

                    cpvm.imageUploadFourth     = imagePath;
                    cpvm.imageUploadFourthName = imageName.ToString();
                }
                UserSession us = new UserSession();
                cpvm.userId = us.userId;
                var prodAdded = await firebase.Child("productMaster").Child(us.userId).PostAsync(cpvm, true);

                data = "Product Added Successfully !";
                ModelState.AddModelError("error", data);
            }
            catch (Exception productAddException)
            {
                var prodError = productAddException.GetType().GetProperty("Reason").GetValue(productAddException, null);
                ModelState.AddModelError("error", prodError.ToString());
                return(View());
            }
            return(RedirectToAction("AddProduct", "Product", new { Status = data }));
        }
示例#9
0
        public async Task <ActionResult> DetailProduct(string productId)
        {
            UserSession us             = new UserSession();
            var         firebase       = FirebaseConnection.FirebaseDatabase();
            var         productDetails = await firebase.Child("productMaster").Child(us.userId).Child(productId).OnceSingleAsync <GetProductViewModel>();

            return(Json(new { productDetails = productDetails }));
        }
 public static FirebaseConnection GetInstance()
 {
     if (_instance == null)
     {
         _instance = FindObjectOfType <FirebaseConnection>();
     }
     return(_instance);
 }
示例#11
0
        public async Task <ActionResult> ActiveInactiveProduct(string productId, string productStatus)
        {
            var sb     = new StringBuilder();
            var action = sb.Append(productStatus).Append("ProductList").ToString();

            sb = new StringBuilder();
            var data = sb.Append("Product ").Append(productStatus).Append(" Failed !").ToString();

            try
            {
                UserSession us             = new UserSession();
                var         firebase       = FirebaseConnection.FirebaseDatabase();
                var         productDetails = await firebase.Child("productMaster").Child(us.userId).Child(productId).OnceSingleAsync <GetProductViewModel>();

                switch (productStatus.ToLower())
                {
                case "inactive":
                    productDetails.productActive = false;
                    break;

                case "active":
                    productDetails.productActive = true;
                    break;

                default:
                    productDetails.productActive = false;
                    break;
                }
                var prodUpdate = firebase.Child("productMaster").Child(us.userId).Child(productId).PutAsync(productDetails);

                //To add only active product list in Product fetch list to website
                switch (productStatus.ToLower())
                {
                case "inactive":
                    await firebase.Child("productFetch").Child(productId).DeleteAsync();

                    break;

                case "active":
                    var prodAdded = firebase.Child("productFetch").Child(productId).PutAsync(productDetails);
                    break;

                default:
                    await firebase.Child("productFetch").Child(productId).DeleteAsync();

                    break;
                }

                data = data.Replace("Failed", "Successfully");
                //data = sb.Append("Product ").Append(productStatus).Append(" Successfully !").ToString();
            }
            catch (Exception productInactiveException)
            {
                var prodError = productInactiveException.GetType().GetProperty("Reason").GetValue(productInactiveException, null);
                data = prodError.ToString();
            }
            return(RedirectToAction(action, "Product", new { Status = data }));
        }
示例#12
0
        private async Task <FirebaseConnection> GetConnectedSUT()
        {
            var cred = JsonFile.Read <FirebaseCredentials>("firebaseConxn.cfg");
            var sut  = new FirebaseConnection(cred);
            var isOK = await sut.Open();

            isOK.Should().BeTrue("Can't connect");
            sut.IsConnected.Should().BeTrue();
            return(sut);
        }
示例#13
0
 void Awake()
 {
     //Singleton instance
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
 }
        private async Task <AgentStateUpdater> GetConnectedSUT()
        {
            var cred = JsonFile.Read <FirebaseCredentials>("firebaseConxn.cfg");

            _conn = new FirebaseConnection(cred);
            var isOK = await _conn.Open();

            isOK.Should().BeTrue("Can't connect");
            _conn.IsConnected.Should().BeTrue();
            var agt = new AgentStateUpdater(_conn, cred);

            _conn.AgentID = Fake.Text;
            return(agt);
        }
示例#15
0
        public async Task <JsonResult> GetProductList(bool productStatus)
        {
            var data = (dynamic)null;

            try
            {
                //var draw = Request.Form.GetValues("draw").FirstOrDefault();
                //var start = Request.Form.GetValues("start").FirstOrDefault();
                //var length = Request.Form.GetValues("length").FirstOrDefault();
                //var sortColumn = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault();
                //var sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault();
                //var searchValue = Request.Form.GetValues("search[value]").FirstOrDefault();
                ////Paging Size (10,20,50,100)
                //int pageSize = length != null ? Convert.ToInt32(length) : 0;
                //int skip = start != null ? Convert.ToInt32(start) : 0;
                //int recordsTotal = 0;
                var         firebase = FirebaseConnection.FirebaseDatabase();
                UserSession us       = new UserSession();
                var         prodList = await firebase.Child("productMaster").Child(us.userId).OrderBy("productActive").EqualTo(productStatus).OnceAsync <GetListProductViewModel>();

                //var prodList = await firebase.Child("productMaster").Child(us.userId).OnceAsync<GetListProductViewModel>();
                var productAdd = new List <GetListProductViewModel>();
                foreach (var p in prodList)
                {
                    p.Object.productId = p.Key;
                    //p.Object.userId = us.userId;
                    productAdd.Add(p.Object);
                }
                ////Sorting
                //if (!(string.IsNullOrEmpty(sortColumn) && string.IsNullOrEmpty(sortColumnDir)))
                //{
                //    productAdd = productAdd.OrderBy(m => m.productTitle).ToList();
                //}
                ////Search
                //if (!string.IsNullOrEmpty(searchValue))
                //{
                //    productAdd = productAdd.Where(m => m.productTitle == searchValue).ToList();
                //}
                data = new { data = productAdd };
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
            }
            return(Json(data, JsonRequestBehavior.AllowGet));

            //recordsTotal = productAdd.Count;
            //productAdd = productAdd.Skip(skip).Take(pageSize).ToList();
        }
        public async Task <JsonResult> LoadProductSize()
        {
            var data     = "Product Size Load Failed !";
            var status   = false;
            var sizeList = (dynamic)null;

            try
            {
                var firebase = FirebaseConnection.FirebaseDatabase();
                sizeList = await firebase.Child("size").OnceAsync <GetProductVarientViewModel>();

                data   = "Product Size Loaded Successfully !";
                status = true;
            }
            catch (Exception sizeLoadException)
            {
                var sizeError = sizeLoadException.GetType().GetProperty("Reason").GetValue(sizeLoadException, null);
            }
            return(Json(new { data = data, status = status, size = sizeList }, JsonRequestBehavior.AllowGet));
        }
        public async Task <JsonResult> LoadSubcategory(string categoryKey)
        {
            var data            = "Subcategory Load Failed !";
            var status          = false;
            var subCategoryList = (dynamic)null;

            try
            {
                var firebase = FirebaseConnection.FirebaseDatabase();
                subCategoryList = await firebase.Child("subCategory").Child(categoryKey).OnceAsync <GetSubcategoryViewModel>();

                data   = "Subcategory Loaded Successfully !";
                status = true;
            }
            catch (Exception subCategoryLoadException)
            {
                var subCategoryError = subCategoryLoadException.GetType().GetProperty("Reason").GetValue(subCategoryLoadException, null);
            }
            return(Json(new { data = data, status = status, subcategory = subCategoryList }, JsonRequestBehavior.AllowGet));
        }
示例#18
0
 public History(Action <SketchModel.Serialization> historyPositionChangedHandler)
 {
     _historyPositionChangedHandler = historyPositionChangedHandler;
     _fb = new FirebaseConnection();
     _fb.Initialize();
 }
示例#19
0
 public JobQueue(FirebaseStorage storage)
 {
     this.storage  = storage;
     connection    = (FirebaseConnection)storage.GetConnection();
     checkInterval = storage.Options.QueuePollInterval;
 }
示例#20
0
        public void Update()
        {
            if (_updateNeeded == true && _callback != null)
            {
                var segmentConfig = _cachedSegmentConfig;
                var deviceInfo    = _deviceInfo;
                try
                {
                    var roundtripTime = Time.time - _startTime;
                    Debug.LogFormat("autotune roundtrip: {0}", roundtripTime);
                    _callback(segmentConfig.settings, segmentConfig.group_id);

                    // should not happen but do not want to write null checks in code below this
                    if (deviceInfo == null)
                    {
                        deviceInfo = new DeviceInfo(_sheetId, _buildVersion);
                    }

                    // device information data should reuse the same naming convention as DeviceInfo event
                    var status = Analytics.CustomEvent("autotune.SegmentRequestInfo", new Dictionary <string, object>()
                    {
                        { "segment_id", segmentConfig.segment_id },
                        { "group_id", segmentConfig.group_id },
                        { "error", _isError },
                        { "player_override", _isPlayerOverride },
                        { "request_latency", roundtripTime },
                        { "model", deviceInfo.model },
                        { "ram", deviceInfo.ram },
                        { "cpu", deviceInfo.cpu },
                        { "cpu_count", deviceInfo.cpu_count },
                        { "gfx_name", deviceInfo.gfx_name },
                        { "gfx_vendor", deviceInfo.gfx_vendor },
                        { "screen", deviceInfo.screen },
                        { "dpi", deviceInfo.dpi },
                        { "gfx_ver", deviceInfo.gfx_ver },
                        { "gfx_shader", deviceInfo.gfx_shader },
                        { "max_texture_size", deviceInfo.max_texture_size },
                        { "os_ver", deviceInfo.os_ver },
                        { "platformid", deviceInfo.platformid },
                        { "app_build_version", _buildVersion },
                        { "plugin_version", AutoTuneMeta.version },
                        { "sheet_id", deviceInfo.sheet_id }
                    });

                    Debug.Log("autotune.SegmentRequestInfo event status: " + status);
                    FirebaseConnection.GetInstance().PushEventStatus(status);

                    var dic = new Dictionary <string, object>()
                    {
                        { "segment_id", segmentConfig.segment_id },
                        { "group_id", segmentConfig.group_id },
                        { "error", _isError },
                        { "player_override", _isPlayerOverride },
                        { "request_latency", roundtripTime },
                        { "model", deviceInfo.model },
                        { "ram", deviceInfo.ram },
                        { "cpu", deviceInfo.cpu },
                        { "cpu_count", deviceInfo.cpu_count },
                        { "gfx_name", deviceInfo.gfx_name },
                        { "gfx_vendor", deviceInfo.gfx_vendor },
                        { "screen", deviceInfo.screen },
                        { "dpi", deviceInfo.dpi },
                        { "gfx_ver", deviceInfo.gfx_ver },
                        { "gfx_shader", deviceInfo.gfx_shader },
                        { "max_texture_size", deviceInfo.max_texture_size },
                        { "os_ver", deviceInfo.os_ver },
                        { "platformid", deviceInfo.platformid },
                        { "app_build_version", _buildVersion },
                        { "plugin_version", AutoTuneMeta.version },
                        { "sheet_id", deviceInfo.sheet_id }
                    };

                    FirebaseConnection.GetInstance().PushAutotuneDic(dic);
                }
                catch (System.Exception e)
                {
                    Debug.LogError(e);
                }
                finally
                {
                    _isError      = false;
                    _updateNeeded = false;
                }
            }
        }
示例#21
0
        public async Task <ActionResult> EditProduct(string productId, EditProductViewModel epvm, string productStatus, ProductImageViewModel pivm)
        {
            var data = "Product Update Failed !";

            try
            {
                var firebase     = FirebaseConnection.FirebaseDatabase();
                var productImage = FirebaseConnection.FirebaseStorageConnection();
                var imageName    = new StringBuilder();
                if (pivm.imageUploadFirst != null)
                {
                    if (!string.IsNullOrEmpty(epvm.imageUploadFirstName))
                    {
                        await productImage.Child("Product").Child(epvm.imageUploadFirstName.Split(',')[1]).DeleteAsync();
                    }
                    imageName.Append(DateTime.Now.ToString("dd_MM_yyyy_hhmmss")).Append(Path.GetExtension(pivm.imageUploadFirst.FileName));
                    var imagePath = await productImage.Child("Product").Child(imageName.ToString()).PutAsync(pivm.imageUploadFirst.InputStream);

                    epvm.imageUploadFirst     = imagePath;
                    epvm.imageUploadFirstName = imageName.ToString();
                }
                else
                {
                    if (string.IsNullOrEmpty(epvm.imageUploadFirstName))
                    {
                        epvm.imageUploadFirst     = null;
                        epvm.imageUploadFirstName = null;
                    }
                    else
                    {
                        var splitImgUrl = epvm.imageUploadFirstName.Split(',');
                        if (splitImgUrl.Length.Equals(2))
                        {
                            epvm.imageUploadFirst     = splitImgUrl[0];
                            epvm.imageUploadFirstName = splitImgUrl[1];
                        }
                        else
                        {
                            epvm.imageUploadFirst     = null;
                            epvm.imageUploadFirstName = null;
                            await productImage.Child("Product").Child(splitImgUrl[1]).DeleteAsync();
                        }
                    }
                }
                if (pivm.imageUploadSecond != null)
                {
                    if (!string.IsNullOrEmpty(epvm.imageUploadSecondName))
                    {
                        await productImage.Child("Product").Child(epvm.imageUploadSecondName.Split(',')[1]).DeleteAsync();
                    }
                    imageName = new StringBuilder();
                    imageName.Append(DateTime.Now.ToString("dd_MM_yyyy_hhmmss")).Append(Path.GetExtension(pivm.imageUploadSecond.FileName));
                    var imagePath = await productImage.Child("Product").Child(imageName.ToString()).PutAsync(pivm.imageUploadSecond.InputStream);

                    epvm.imageUploadSecond     = imagePath;
                    epvm.imageUploadSecondName = imageName.ToString();
                }
                else
                {
                    if (string.IsNullOrEmpty(epvm.imageUploadSecondName))
                    {
                        epvm.imageUploadSecond     = null;
                        epvm.imageUploadSecondName = null;
                    }
                    else
                    {
                        var splitImgUrl = epvm.imageUploadSecondName.Split(',');
                        if (splitImgUrl.Length.Equals(2))
                        {
                            epvm.imageUploadSecond     = splitImgUrl[0];
                            epvm.imageUploadSecondName = splitImgUrl[1];
                        }
                        else
                        {
                            epvm.imageUploadSecond     = null;
                            epvm.imageUploadSecondName = null;
                            await productImage.Child("Product").Child(splitImgUrl[1]).DeleteAsync();
                        }
                    }
                }
                if (pivm.imageUploadThird != null)
                {
                    if (!string.IsNullOrEmpty(epvm.imageUploadThirdName))
                    {
                        await productImage.Child("Product").Child(epvm.imageUploadThirdName.Split(',')[1]).DeleteAsync();
                    }
                    imageName = new StringBuilder();
                    imageName.Append(DateTime.Now.ToString("dd_MM_yyyy_hhmmss")).Append(Path.GetExtension(pivm.imageUploadThird.FileName));
                    var imagePath = await productImage.Child("Product").Child(imageName.ToString()).PutAsync(pivm.imageUploadThird.InputStream);

                    epvm.imageUploadThird     = imagePath;
                    epvm.imageUploadThirdName = imageName.ToString();
                }
                else
                {
                    if (string.IsNullOrEmpty(epvm.imageUploadThirdName))
                    {
                        epvm.imageUploadThird     = null;
                        epvm.imageUploadThirdName = null;
                    }
                    else
                    {
                        var splitImgUrl = epvm.imageUploadThirdName.Split(',');
                        if (splitImgUrl.Length.Equals(2))
                        {
                            epvm.imageUploadThird     = splitImgUrl[0];
                            epvm.imageUploadThirdName = splitImgUrl[1];
                        }
                        else
                        {
                            epvm.imageUploadThird     = null;
                            epvm.imageUploadThirdName = null;
                            await productImage.Child("Product").Child(splitImgUrl[1]).DeleteAsync();
                        }
                    }
                }
                if (pivm.imageUploadFourth != null)
                {
                    if (!string.IsNullOrEmpty(epvm.imageUploadFourthName))
                    {
                        await productImage.Child("Product").Child(epvm.imageUploadFourthName.Split(',')[1]).DeleteAsync();
                    }
                    imageName = new StringBuilder();
                    imageName.Append(DateTime.Now.ToString("dd_MM_yyyy_hhmmss")).Append(Path.GetExtension(pivm.imageUploadFourth.FileName));
                    var imagePath = await productImage.Child("Product").Child(imageName.ToString()).PutAsync(pivm.imageUploadFourth.InputStream);

                    epvm.imageUploadFourth     = imagePath;
                    epvm.imageUploadFourthName = imageName.ToString();
                }
                else
                {
                    if (string.IsNullOrEmpty(epvm.imageUploadFourthName))
                    {
                        epvm.imageUploadFourth     = null;
                        epvm.imageUploadFourthName = null;
                    }
                    else
                    {
                        var splitImgUrl = epvm.imageUploadFourthName.Split(',');
                        if (splitImgUrl.Length.Equals(2))
                        {
                            epvm.imageUploadFourth     = splitImgUrl[0];
                            epvm.imageUploadFourthName = splitImgUrl[1];
                        }
                        else
                        {
                            epvm.imageUploadFourth     = null;
                            epvm.imageUploadFourthName = null;
                            await productImage.Child("Product").Child(splitImgUrl[1]).DeleteAsync();
                        }
                    }
                }
                UserSession us = new UserSession();
                epvm.userId = us.userId;
                var prodUpdate = firebase.Child("productMaster").Child(us.userId).Child(productId).PutAsync(epvm);
                data = "Product Updated Successfully !";
            }
            catch (Exception productEditException)
            {
                var prodError = productEditException.GetType().GetProperty("Reason").GetValue(productEditException, null);
                ModelState.AddModelError("error", prodError.ToString());
                return(View());
            }
            var sb     = new StringBuilder();
            var action = sb.Append(productStatus).Append("ProductList").ToString();

            return(RedirectToAction(action, "Product", new { Status = data }));
        }
示例#22
0
 public JobQueueMonitoringApi(FirebaseStorage storage)
 {
     connection = (FirebaseConnection)storage.GetConnection();
     queues     = storage.Options.Queues;
 }