Esempio n. 1
0
        public ActionResult Create()
        {
            var Details = new EmpDetailsClass();

            Details.RowKey = new Random().Next().ToString();
            return(View(Details));
        }
        public ActionResult Create()
        {
            var Details = new EmpDetailsClass();

            Details.RowKey = new Random().Next().ToString(); //Generate the Employee Id Randomly
            return(View(Details));
        }
        public ActionResult Create(EmpDetailsClass collection)
        {
            try
            {
                EmpDetailsClass emp = new EmpDetailsClass(collection.EmpId, collection.Email);
                emp.EmpId       = Convert.ToInt32(collection.EmpId);
                emp.EmpName     = collection.EmpName;
                emp.Designation = collection.Designation;
                emp.Email       = collection.Email;

                //Creates table client object
                CloudTableClient tableClient = cloudStorageAccount.CreateCloudTableClient();

                CloudTable table = tableClient.GetTableReference("EmployeeTable");

                //Create a Table Operation
                TableOperation insertOperation = TableOperation.InsertOrReplace(emp);
                table.Execute(insertOperation);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
        //Method to Create Entity
        public void CreateEntity(EmpDetailsClass entity)
        {
            CloudTable table = tableClient.GetTableReference("EmployeeTable");
            //Create a TableOperation object used to insert Entity into Table
            TableOperation insertOperation = TableOperation.Insert(entity);

            //Execute an Insert Operation
            table.Execute(insertOperation);
        }
Esempio n. 5
0
        public async Task <ActionResult> Create(EmpDetailsClass obj, HttpPostedFileBase profileFile)
        {
            CloudBlockBlob profileBlob = null;

            //Step 1: Uploaded File in BLob Storage
            if (profileFile != null && profileFile.ContentLength != 0)
            {
                profileBlob = await blobOperations.UploadBlob(profileFile, obj.RowKey);

                obj.ProfileImage = profileBlob.Uri.ToString();
            }
            //Step 2: Save the Information in the Table Storage
            tableOperations.CreateEntity(obj);
            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Create(
            EmpDetailsClass obj,
            HttpPostedFileBase profileFile

            )
        {
            CloudBlockBlob profileBlob = null;

            #region Upload File In Blob Storage
            //Step 1: Uploaded File in BLob Storage
            if (profileFile != null && profileFile.ContentLength != 0)
            {
                profileBlob = await blobOperations.UploadBlob(profileFile);

                obj.ProfileImage = profileBlob.Uri.ToString();
            }
            //Ends Here
            #endregion

            //Que Storeage executio
            #region Azure web jobs
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["empstorage"]);
            // Create the queue client
            CloudQueueClient queueclinet = storageAccount.CreateCloudQueueClient();

            // Retrieve a reference to queue
            CloudQueue queue = queueclinet.GetQueueReference("quwuw");
            //Create the Queue if it doesn't already exist.

            queue.CreateIfNotExists();
            CloudQueueMessage message = new CloudQueueMessage(profileBlob.Name);
            queue.AddMessage(message);
            #endregion


            #region Save Information in Table Storage
            //Step 2: Save the Information in the Table Storage
            //Get the Original File Size
            obj.RowKey       = obj.EmpId.ToString();
            obj.PartitionKey = obj.Email;
            //Save the File in the Table
            tableOperations.CreateEntity(obj);
            //Ends Here
            #endregion
            return(RedirectToAction("Index"));
        }
        public List <EmpDetailsClass> EditEntity(EmpDetailsClass editEntity)
        {
            if (editEntity == null)
            {
                throw new ArgumentNullException("editEntity");
            }
            List <EmpDetailsClass> Details = new List <EmpDetailsClass>();
            CloudTable             table   = tableClient.GetTableReference("EmployeeTable");

            editEntity.ETag = "*";
            TableOperation deleteOperation = TableOperation.Replace(editEntity);

            table.Execute(deleteOperation);
            var details = GetEntities();
                        // Get the request units consumed by the current operation. RequestCharge of a TableResult is only applied to Azure CosmoS DB 
                        return(details);
        }
Esempio n. 8
0
        public List <EmpDetailsClass> UpdateEntity(EmpDetailsClass updateEntity)
        {
            if (updateEntity == null)
            {
                throw new ArgumentNullException("updateEntity");
            }
            List <EmpDetailsClass> Details = new List <EmpDetailsClass>();

            CloudTable table = tableClient.GetTableReference("EmployeeTable");

            updateEntity.ETag = "*";
            TableOperation editOperation = TableOperation.Replace(updateEntity);

            //string cdnurl = ConfigurationManager.AppSettings["cdnurl"];
            table.Execute(editOperation);
            var details = GetEntities();
                        // Get the request units consumed by the current operation. RequestCharge of a TableResult is only applied to Azure CosmoS DB 
                        return(details);
        }
        public ActionResult Update(EmpDetailsClass entity)
        {
            var details = tableOperations.EditEntity(entity);

            return(RedirectToAction("Index"));
        }
 public ActionResult Edit(EmpDetailsClass entity)
 {
     return(View());
 }
Esempio n. 11
0
        public ActionResult Delete(EmpDetailsClass entity)
        {
            var Details = tableOperations.DeleteEntity(entity);

            return(RedirectToAction("Index"));
        }