Ejemplo n.º 1
0
        public IActionResult Edit(UserEntity user)
        {
            int errorCode = 0;

            try
            {
                if ((HttpContext?.User?.Identity?.Name ?? "").Trim().ToLower().Equals((user?.RowKey?.Trim()?.ToLower() ?? "Q!@QQW@!")) ||
                    (HttpContext?.User?.Identity?.Name ?? "") == "sachin")
                {
                    user.ETag = "*";
                    TableStorageHelper.MergeAsync(Constants.TABLE_USER, user).Wait();

                    CacheHelper.ClearUsersCache();
                }
                else
                {
                    errorCode = Constants.ERROR_CODE_ACCESS_DENIED;
                }
            }
            catch (Exception ex)
            {
                if (!TableStorageHelper.IsStorageException(ex, out errorCode))
                {
                    errorCode = Constants.ERROR_CODE_COMMON;
                }
            }

            return(RedirectToAction("Index", new { errorCode = errorCode }));
        }
Ejemplo n.º 2
0
        public IActionResult Edit(TechnologyEntity technology, string OriginalNameHash, bool isSubcategoryInQuery)
        {
            int errorCode = 0;

            try
            {
                technology.Description = technology.Description ?? "";

                technology.Tag = InsertTag(technology.NewTag, technology.Tag);

                if (OriginalNameHash.Equals(technology.NameHash))
                {
                    TableStorageHelper.MergeAsync(Constants.TABLE_TECHNOLOGY, technology).Wait();
                }
                else
                {
                    DuplicateCheckEntity duplicateCheckOriginalDelete = new DuplicateCheckEntity(technology.PartitionKey, technology.SubcategoryID + "_" + OriginalNameHash);
                    duplicateCheckOriginalDelete.ETag = "*";

                    DuplicateCheckEntity duplicateCheckNewAdd = new DuplicateCheckEntity(technology.PartitionKey, technology.SubcategoryID + "_" + technology.NameHash);

                    TableStorageHelper.BatchAsync(Constants.TABLE_TECHNOLOGY, new DuplicateCheckEntity[] { duplicateCheckOriginalDelete }, new DuplicateCheckEntity[] { duplicateCheckNewAdd }, new TechnologyEntity[] { technology }).Wait();
                }
            }
            catch (Exception ex)
            {
                if (!TableStorageHelper.IsStorageException(ex, out errorCode))
                {
                    errorCode = Constants.ERROR_CODE_COMMON;
                }
            }

            return(RedirectToAction("Index", new { errorCode = errorCode, category = technology.PartitionKey, subcategory = ((isSubcategoryInQuery) ? technology.SubcategoryID : ""), technology = technology.ID }));
        }
Ejemplo n.º 3
0
        public IActionResult Edit(CategoryEntity entity)
        {
            int errorCode = 0;

            try
            {
                if (CacheHelper.GetCategoryList(entity.PartitionKey).Count(cat => cat.NameHash.Equals(entity.NameHash) && !cat.ID.Equals(entity.ID)) > 0)
                {
                    errorCode = Constants.ERROR_CODE_ENTITY_ALREADY_EXISTS;
                }
                else
                {
                    TableStorageHelper.MergeAsync(Constants.TABLE_CATEGORY, entity).Wait();

                    CacheHelper.ClearCategoryListCache();
                }
            }
            catch (Exception ex)
            {
                if (!TableStorageHelper.IsStorageException(ex, out errorCode))
                {
                    errorCode = Constants.ERROR_CODE_COMMON;
                }
            }

            return(RedirectToAction("Index", new { category = entity.PartitionKey, errorCode = errorCode }));
        }