Example #1
0
        public IActionResult Add(TechnologyEntity technology, string StatusRemarks, bool isSubcategoryInQuery)
        {
            int    errorCode = 0;
            string nextID    = "";

            try
            {
                nextID = SequenceHelper.GetNextSequence(Constants.ID, Constants.TABLE_TECHNOLOGY, Constants.PADDING_TECHNOLOGYID);

                technology.RowKey = technology.RowKey + "_" + nextID;

                technology.Description = technology.Description ?? "";

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

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

                TechnologyStatusEntity technologyStatus = GetTechnologyStatusEntity(technology.PartitionKey, nextID, technology.Status, StatusRemarks);

                TableStorageHelper.InsertBatchAsync(Constants.TABLE_TECHNOLOGY, duplicateCheck, technology, technologyStatus).Wait();
            }
            catch (Exception ex)
            {
                nextID = "";
                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 = nextID }));
        }