Exemplo n.º 1
0
        public PRODUCT_DEVELOPMENT ChangeStatus(string id, Core.ReferenceKeys.ApprovalStatus status, int formType, int actionType, int role, string user, string comment = null)
        {
            using (var context = new EMSDataModel())
            {
                using (var transaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        var old  = context.PRODUCT_DEVELOPMENT.Find(id);
                        var data = (PRODUCT_DEVELOPMENT)context.Entry(old).GetDatabaseValues().ToObject();
                        //data.STATUS_APPROVAL = refService.GetReferenceByKey(status).REFF_ID;
                        //if (status == Core.ReferenceKeys.ApprovalStatus.Completed)
                        //{
                        //    data.LASTAPPROVED_BY = user;
                        //    data.LASTAPPROVED_DATE = DateTime.Now;
                        //}
                        //else if (status == Core.ReferenceKeys.ApprovalStatus.AwaitingAdminApproval)
                        //{
                        //    data.LASTMODIFIED_BY = user;
                        //    data.LASTMODIFIED_DATE = DateTime.Now;
                        //}

                        //data.APPROVAL_STATUS = context.SYS_REFFERENCES.Find(data.STATUS_APPROVAL);
                        //Dictionary<string, string[]> changes = GetAllChanges(old, data);
                        //context.Entry(old).CurrentValues.SetValues(data);
                        //context.SaveChanges();
                        //LogsActivity(context, data, changes, formType, actionType, role, user, comment);
                        //transaction.Commit();

                        return(data);
                    }
                    catch (Exception ex)
                    {
                        throw this.HandleException("Exception occured on Brand Registration Service. See Inner Exception property to see details", ex);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public MASTER_FINANCIAL_RATIO ChangeStatus(long id, Core.ReferenceKeys.ApprovalStatus status, int formType, int actionType, int role, string user, string comment = null)
        {
            using (var context = new EMSDataModel())
            {
                using (var transaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        var old  = context.MASTER_FINANCIAL_RATIO.Find(id);
                        var data = (MASTER_FINANCIAL_RATIO)context.Entry(old).GetDatabaseValues().ToObject();
                        data.STATUS_APPROVAL = refService.GetReferenceByKey(status).REFF_ID;
                        if (status == Core.ReferenceKeys.ApprovalStatus.Completed)
                        {
                            data.LASTAPPROVED_BY   = user;
                            data.LASTAPPROVED_DATE = DateTime.Now;
                        }
                        else if (status == Core.ReferenceKeys.ApprovalStatus.AwaitingAdminApproval)
                        {
                            data.LASTMODIFIED_BY   = user;
                            data.LASTMODIFIED_DATE = DateTime.Now;
                        }
                        data.COMPANY        = context.T001.Find(data.BUKRS);
                        data.APPROVALSTATUS = context.SYS_REFFERENCES.Find(data.STATUS_APPROVAL);
                        Dictionary <string, string[]> changes = GetAllChanges(old, data);
                        context.Entry(old).CurrentValues.SetValues(data);
                        context.SaveChanges();
                        LogsActivity(context, data, changes, formType, actionType, role, user, comment);
                        transaction.Commit();

                        return(data);
                    }
                    catch (Exception ex)
                    {
                        throw this.HandleException("Exception occured on FinanceRatioManagementService. See Inner Exception property to see details", ex);
                    }
                }
            }
        }