Exemple #1
0
 public static DraftPlanDTO ToDTO(this DraftPlan source)
 {
     throw new NotImplementedException();
     return(source == null ? null
         : new DraftPlanDTO(source)
     {
     });
 }
Exemple #2
0
        public OperationResult UpDateDraftData(SubmissionProcessViewModel input, int Id)
        {
            OperationResult result       = new OperationResult();
            var             member       = _repository.GetAll <Member>().Where((x) => x.MemberId == Id).FirstOrDefault();
            var             draftProject = _repository.GetAll <DraftProject>().Where((x) => x.DraftProjectId == input.DraftProjectId).FirstOrDefault();

            result.Status = member.MemberId;
            //using (var transaction = _context.Database.BeginTransaction())
            //{
            try
            {
                member.MemberConEmail = input.MemberConEmail;
                member.MemberPhone    = input.MemberPhone;
                member.ProfileImgUrl  = input.ProfileImgUrl;
                member.AboutMe        = input.AboutMe;
                member.MemberWebsite  = input.MemberWebsite;
                member.MemberName     = input.CreatorName; //可以同步更動改會員名

                _repository.Update(member);
                result.IsSuccessful = true;

                draftProject.MemberId               = member.MemberId; //foreign
                draftProject.DraftProjectName       = input.ProjectName;
                draftProject.AmountThreshold        = input.AmountThreshold;
                draftProject.Category               = input.Category;
                draftProject.StartDate              = DateTime.ParseExact(input.StartDate, "yyyyMMdd", null);
                draftProject.EndDate                = DateTime.ParseExact(input.EndDate, "yyyyMMdd", null);
                draftProject.DraftProjectVideoUrl   = input.ProjectVideoUrl;
                draftProject.DraftProjectMainUrl    = input.ProjectMainUrl;
                draftProject.DraftProjectCoverUrl   = input.ProjectCoverUrl;
                draftProject.DraftProjectPrincipal  = input.ProjectPrincipal;
                draftProject.IdentityNumber         = input.IdentityNumber;
                draftProject.CreatorName            = input.CreatorName;
                draftProject.DraftProjectImgUrl     = input.ProjectImgUrl;
                draftProject.DraftProject_Question  = input.Project_Question;
                draftProject.DraftProject_Answer    = input.Project_Answer;
                draftProject.DraftProjectPlansCount = input.DraftProjectPlansCount;
                //draftProject.ProjectStatus = "審核中";
                draftProject.DraftCreatedDate   = input.CreatedDate;
                draftProject.DraftSubmittedDate = input.SubmittedDate;
                draftProject.DraftLastEditTime  = input.LastEditTime;

                _repository.Update(draftProject);
                result.IsSuccessful = true;

                if (input.PlanObject != null)
                {
                    //刪掉原本的
                    var draftPlanObj = _repository.GetAll <DraftPlan>().Where((x) => x.DraftProjectId == draftProject.DraftProjectId).ToList();
                    //var draftPlanObj2 = _prcontext.DraftPlans.Where((x) => x.DraftProjectId == draftProject.DraftProjectId);
                    foreach (var item in draftPlanObj)
                    {
                        _repository.Delete(item);
                    }

                    //重新加新的plan
                    List <SubmissionProcessPlanViewModel> planObj = input.PlanObject;
                    foreach (var item in planObj)
                    {
                        DraftPlan pl_entity = new DraftPlan
                        {
                            DraftProjectId       = draftProject.DraftProjectId,   //foreign
                            DraftProjectName     = draftProject.DraftProjectName, //同步寫入
                            DraftProjectPlanId   = item.ProjectPlanId,
                            DraftPlanPrice       = item.PlanPrice,
                            DraftPlanTitle       = item.PlanTitle,
                            DraftQuantityLimit   = item.QuantityLimit,
                            DraftPlanDescription = item.PlanDescription,
                            DraftPlanImgUrl      = item.PlanImgUrl,
                            DraftPlanShipDate    = DateTime.ParseExact(item.PlanShipDate, "yyyyMMdd", null),
                            DraftAddCarCarPlan   = item.AddCarCarPlan,
                        };
                        _repository.Create(pl_entity);
                        result.IsSuccessful = true;
                    }
                }
            }
            catch (Exception ex)
            {
                result.Exception    = ex;
                result.DateTime     = DateTime.Now;
                result.IsSuccessful = false;
                //transaction.Rollback();
            }
            //}
            return(result);
        }
Exemple #3
0
        public OperationResult ReceiveDraftData(SubmissionProcessViewModel input, int Id)
        {
            OperationResult result = new OperationResult();
            var             member = _repository.GetAll <Member>().Where((x) => x.MemberId == Id).FirstOrDefault();

            result.Status = member.MemberId;
            //using (var transaction = _context.Database.BeginTransaction())
            //{
            try
            {
                member.MemberConEmail = input.MemberConEmail;
                member.MemberPhone    = input.MemberPhone;
                member.ProfileImgUrl  = input.ProfileImgUrl;
                member.AboutMe        = input.AboutMe;
                member.MemberWebsite  = input.MemberWebsite;
                member.MemberName     = input.CreatorName; //可以同步更動改會員名

                _repository.Update(member);
                result.IsSuccessful = true;

                //

                DraftProject pr_entity = new DraftProject
                {
                    MemberId               = member.MemberId, //foreign
                    DraftProjectName       = input.ProjectName,
                    AmountThreshold        = input.AmountThreshold,
                    Category               = input.Category,
                    StartDate              = DateTime.ParseExact(input.StartDate, "yyyyMMdd", null),
                    EndDate                = DateTime.ParseExact(input.EndDate, "yyyyMMdd", null),
                    DraftProjectVideoUrl   = input.ProjectVideoUrl,
                    DraftProjectMainUrl    = input.ProjectMainUrl,
                    DraftProjectCoverUrl   = input.ProjectCoverUrl,
                    DraftProjectPrincipal  = input.ProjectPrincipal,
                    IdentityNumber         = input.IdentityNumber,
                    CreatorName            = input.CreatorName,
                    DraftProjectImgUrl     = input.ProjectImgUrl,
                    DraftProject_Question  = input.Project_Question,
                    DraftProject_Answer    = input.Project_Answer,
                    DraftProjectPlansCount = input.DraftProjectPlansCount,
                    //ProjectStatus = "審核中",
                    DraftCreatedDate   = input.CreatedDate,
                    DraftSubmittedDate = input.SubmittedDate,
                    DraftLastEditTime  = input.LastEditTime,
                    FundingAmount      = 0,
                    Fundedpeople       = 0,
                    ApprovingStatus    = 0,
                };
                _repository.Create(pr_entity);
                result.IsSuccessful = true;

                //

                if (input.PlanObject != null)
                {
                    List <SubmissionProcessPlanViewModel> planObj = input.PlanObject;
                    foreach (var item in planObj)
                    {
                        DraftPlan pl_entity = new DraftPlan
                        {
                            DraftProjectId       = pr_entity.DraftProjectId,   //foreign
                            DraftProjectName     = pr_entity.DraftProjectName, //同步寫入
                            DraftProjectPlanId   = item.ProjectPlanId,
                            DraftPlanPrice       = item.PlanPrice,
                            DraftPlanTitle       = item.PlanTitle,
                            DraftQuantityLimit   = item.QuantityLimit,
                            DraftPlanDescription = item.PlanDescription,
                            DraftPlanImgUrl      = item.PlanImgUrl,
                            DraftPlanShipDate    = DateTime.ParseExact(item.PlanShipDate, "yyyyMMdd", null),
                            DraftAddCarCarPlan   = item.AddCarCarPlan,
                        };
                        _repository.Create(pl_entity);
                        result.IsSuccessful = true;
                    }
                }
            }
            catch (Exception ex)
            {
                result.Exception    = ex;
                result.DateTime     = DateTime.Now;
                result.IsSuccessful = false;
                //transaction.Rollback();
            }
            //}
            return(result);
        }