コード例 #1
0
        /// <summary>
        /// Deletes the asynchronous.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public async Task<SaveResult> DeleteAsync(MSTProcessTypesDto entity)
        {
            SaveResult result = SaveResult.FAILURE;

            try
            {
                using (FailureAnalysisEntities context = new FailureAnalysisEntities())
                {
                    var assembly = context.MST_ProcessTypes.Single(x => x.Id == entity.Id && x.IsDeleted == false);
                    assembly.IsDeleted = true;

                    context.Entry<MST_ProcessTypes>(assembly).State = System.Data.Entity.EntityState.Modified;
                    result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE;
                }
            }
            catch (Exception ex)
            {
                _logService.Error(ex.Message, ex);
                result = SaveResult.FAILURE;
            }

            return result;
        }
コード例 #2
0
        /// <summary>
        /// Updates the asynchronous.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public async Task<SaveResult> UpdateAsync(MSTProcessTypesDto entity)
        {
            SaveResult result = SaveResult.FAILURE;

            try
            {
                using (FailureAnalysisEntities context = new FailureAnalysisEntities())
                {
                    var update = context.MST_ProcessTypes.Single(x => x.Id == entity.Id && x.IsDeleted == false);

                    update.Id = entity.Id;
                    update.Name = entity.Name;
                    update.SeqNumber = entity.SeqNumber;
                    update.Duration = entity.Duration;
                    update.IsDeleted = entity.IsDeleted;
                    update.Description = entity.Description;
                    update.LastUpdatedBy = entity.LastUpdatedBy;
                    update.LastUpdate = DateTime.Now;

                    context.Entry<MST_ProcessTypes>(update).State = System.Data.Entity.EntityState.Modified;
                    result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE;
                }
            }
            catch (Exception ex)
            {
                _logService.Error(ex.Message, ex);
                result = SaveResult.FAILURE;
            }

            return result;
        }
コード例 #3
0
        /// <summary>
        /// Adds the asynchronous.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public async Task<SaveResult> AddAsync(MSTProcessTypesDto entity)
        {
            SaveResult result = SaveResult.FAILURE;
            try
            {
                using (FailureAnalysisEntities context = new FailureAnalysisEntities())
                {
                    MST_ProcessTypes add = context.MST_ProcessTypes.Create();

                    add.Description = entity.Description;
                    add.Name = entity.Name;
                    add.SeqNumber = entity.SeqNumber;
                    add.Duration = entity.Duration;
                    add.IsDeleted = false;
                    add.LastUpdatedBy = entity.LastUpdatedBy;
                    add.LastUpdate = DateTime.Now;

                    context.Entry<MST_ProcessTypes>(add).State = System.Data.Entity.EntityState.Added;
                    result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE;
                }
            }
            catch (Exception ex)
            {
                _logService.Error(ex.Message, ex);
                result = SaveResult.FAILURE;
            }
            return result;
        }
コード例 #4
0
        public async Task<ActionResult> Create(ProcessTypeViewModel processtype)
        {
            if (ModelState.IsValid)
            {
                MSTProcessTypesDto data = new MSTProcessTypesDto
                {
                    Name = processtype.Name,
                    Description = processtype.Description,
                    Duration = processtype.Duration,
                    SeqNumber = processtype.SeqNumber,
                    LastUpdatedBy = this.CurrentName,
                };
                var result = await ProcessTypesRepository.AddAsync(data);
                if (result == Model.SaveResult.SUCCESS)
                    return RedirectToAction("Index");
            }

            return View(processtype);
        }