public IActionResult SetDefaultUpdateByForStatusHistory(string username) { try { username = username?.Trim() ?? ""; if (HttpContext.User.Identity.Name.Equals("sachin") && username.Length > 0) { foreach (CategoryEntity category in CacheHelper.GetCategoryList(Constants.BASE_CATEGORY)) { IEnumerable <TechnologyStatusEntity> statuses = TableStorageHelper.RetrieveByRangeAsync <TechnologyStatusEntity>(Constants.TABLE_TECHNOLOGY, category.ID, "ge", "S", "lt", "T").Result; foreach (TechnologyStatusEntity status in statuses) { if (string.IsNullOrEmpty(status?.Username?.Trim())) { status.Username = username; } } TableStorageHelper.BatchAsync(Constants.TABLE_TECHNOLOGY, null, null, statuses.ToArray()).Wait(); } ViewData["ExecutionStatus"] = "Succeed."; } else { ViewData["ExecutionStatus"] = "Failed."; } } catch { ViewData["ExecutionStatus"] = "Failed."; } return(View()); }
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 })); }
//public IActionResult Delete(CategoryEntity entity) //{ // int errorCode = 0; // try // { // entity.Visibility = false; // 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 }); //} public IActionResult Sort(CategoryEntity up, CategoryEntity down) { int errorCode = 0; try { CategoryEntity newUp = new CategoryEntity(up.PartitionKey, up.RowKey); CategoryEntity newDown = new CategoryEntity(down.PartitionKey, down.RowKey); up.CopyTo(newUp, false); down.CopyTo(newDown, false); string upSortNumber = up.RowKey.Split('_')[0]; string downSortNumber = down.RowKey.Split('_')[0]; newUp.RowKey = downSortNumber + "_" + newUp.ID; newDown.RowKey = upSortNumber + "_" + newDown.ID; TableStorageHelper.BatchAsync(Constants.TABLE_CATEGORY, new CategoryEntity[] { up, down }, new CategoryEntity[] { newUp, newDown }, null).Wait(); CacheHelper.ClearCategoryListCache(); } catch (Exception ex) { if (!TableStorageHelper.IsStorageException(ex, out errorCode)) { errorCode = Constants.ERROR_CODE_COMMON; } } return(RedirectToAction("Index", new { category = up.PartitionKey, errorCode = errorCode })); }
public IActionResult UpdateStatus(TechnologyEntity technology, string StatusRemarks, bool isSubcategoryInQuery) { int errorCode = 0; try { technology.Description = technology.Description ?? ""; TechnologyStatusEntity technologyStatus = GetTechnologyStatusEntity(technology.PartitionKey, technology.ID, technology.Status, StatusRemarks); TableStorageHelper.BatchAsync(Constants.TABLE_TECHNOLOGY, null, new TechnologyStatusEntity[] { technologyStatus }, 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 })); }