public async Task <IActionResult> Index()
        {
            var users = UserMgr.Users.ToList();

            MergeModel model = new MergeModel();

            List <BugAssignmentHistory> bugHistoryList =
                new List <BugAssignmentHistory>();

            foreach (var user in users)
            {
                if (await UserMgr.IsInRoleAsync(user, "Developer"))
                {
                    var bugHistory = _context
                                     .BugAssignmentHistories
                                     .Where(bh => bh.AssignedToId == user.Id);

                    bugHistoryList.AddRange(bugHistory);
                }
            }

            //gray
            model.ApprovalStatusCount = GetTeamProgressData(bugHistoryList, BugStatusEnum.AwaitingApproval);

            //blue
            model.InProgressStatusCount = GetTeamProgressData(bugHistoryList, BugStatusEnum.InProgress);

            //green
            model.DoneStatusCount = GetTeamProgressData(bugHistoryList, BugStatusEnum.Done);

            //purple
            model.CompletedStatusCount = GetTeamProgressData(bugHistoryList, BugStatusEnum.Completed);

            return(View(model));
        }
        public async Task<IActionResult> SearchResults()
        {
            //Get GIF Image
            string searchQuery = Request.Form[nameof(gifsearch)];
            var result = await _giphyServices.GetRandomGifBasedOnSearchCritera(searchQuery);

            //Get Joke
            var client = new HttpClient();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            var url = new Uri($"https://icanhazdadjoke.com/search?term={searchQuery}");
            var response = await client.GetAsync(url);
            string json;
            using (var content = response.Content)
            {
                json = await content.ReadAsStringAsync();
            }
            var joke = JsonConvert.DeserializeObject<JokeModel>(json);

            //Merge Results
            MergeModel model = new MergeModel();
            model.gifResult = result;
            model.jokeResult = joke;
            
            return View(model);
        }
Example #3
0
 public ActionResult MergeFieldsAndMoveRelated(MergeModel m)
 {
     m.LogMerge("Merge and move related");
     m.Update();
     m.Move();
     return(Redirect("/Person2/" + m.pi[1].PeopleId));
 }
Example #4
0
        public ActionResult Index(int?PeopleId1, int?PeopleId2)
        {
            if (!PeopleId1.HasValue || !PeopleId2.HasValue)
            {
                return(Content("need PeopleId1 and PeopleId2"));
            }
            var m = new MergeModel(PeopleId1.Value, PeopleId2.Value);

            if (m.pi.Count != 3)
            {
                if (m.pi.Count == 2)
                {
                    if (m.pi[0].PeopleId != PeopleId1.Value)
                    {
                        return(Content("peopleid {0} not found".Fmt(PeopleId1.Value)));
                    }
                    else
                    {
                        return(Content("peopleid {0} not found".Fmt(PeopleId2.Value)));
                    }
                }
                else if (m.pi.Count == 1)
                {
                    return(Content("neither peopleid found"));
                }
            }
            return(View(m));
        }
Example #5
0
        private void LoadValuesFromSession()
        {
            if (this.Session["Product"] == null)
            {
                return;
            }

            this.model = this.Session["Product"] as MergeModel;

            if (this.model == null)
            {
                return;
            }

            this.PartyCodeHidden.Value   = this.model.PartyCode.ToString(LocalizationHelper.GetCurrentCulture());
            this.PartyCodeTextBox.Text   = this.model.PartyCode.ToString(LocalizationHelper.GetCurrentCulture());
            this.PriceTypeIdHidden.Value = this.model.PriceTypeId.ToString(SessionHelper.GetCulture());

            this.ReferenceNumberTextBox.Text    = this.model.ReferenceNumber;
            this.StatementReferenceTextBox.Text = this.model.StatementReference;

            this.Session[this.ID]            = this.model.View;
            this.Session["TranIdCollection"] = this.model.TransactionIdCollection;
            this.ClearSession("Product");
        }
Example #6
0
 public ActionResult Run(string submit, bool?Delete, MergeModel m)
 {
     if (submit.StartsWith("Merge Fields"))
     {
         DbUtil.LogActivity("Merging Fields from {0} to {1}".Fmt(m.pi[0].PeopleId, m.pi[1].PeopleId));
         m.Update();
     }
     if (submit == "Merge Fields and Move Related Records")
     {
         DbUtil.LogActivity("Moving records from {0} to {1}".Fmt(m.pi[0].PeopleId, m.pi[1].PeopleId));
         m.Move();
         if (Delete == true)
         {
             DbUtil.LogActivity("Deleting Record during Merge {0}".Fmt(m.pi[0].PeopleId));
             m.Delete();
         }
     }
     if (submit == "Toggle Not Duplicate")
     {
         if (m.pi[0].notdup || m.pi[1].notdup)
         {
             var dups = DbUtil.Db.PeopleExtras.Where(ee => ee.Field == "notdup" && (ee.PeopleId == m.pi[0].PeopleId || ee.PeopleId == m.pi[1].PeopleId));
             DbUtil.Db.PeopleExtras.DeleteAllOnSubmit(dups);
         }
         else
         {
             m.pi[0].person.AddEditExtraInt("notdup", m.pi[1].PeopleId);
             m.pi[1].person.AddEditExtraInt("notdup", m.pi[0].PeopleId);
         }
         DbUtil.Db.SubmitChanges();
         return(Redirect("/Merge/Index?PeopleId1={0}&PeopleId2={1}".Fmt(m.pi[0].PeopleId, m.pi[1].PeopleId)));
     }
     return(Redirect("/Person/Index/" + m.pi[1].PeopleId));
 }
Example #7
0
        public async Task <IActionResult> Register(MergeModel user)
        {
            try
            {
                ViewBag.Message = "User already registered.";
                AppUser appuser = await UserMgr.FindByNameAsync(user.AppUsers.UserName);

                if (appuser == null)
                {
                    appuser           = new AppUser();
                    appuser.UserName  = user.AppUserName;
                    appuser.Email     = user.AppUserEmail;
                    appuser.FirstName = user.AppUsers.FirstName;
                    appuser.LastName  = user.AppUsers.LastName;

                    IdentityResult result = await UserMgr.CreateAsync(appuser, user.AppUserPassword);

                    ViewBag.Message = "User was successfully created!";

                    return(RedirectToAction("Login"));
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
            }

            return(View());
        }
Example #8
0
        public IActionResult Post([FromForm] MergeModel model)
        {
            if (!Arguments.HasValue(model.EntityId, model.RecordId1, model.RecordId2))
            {
                return(JError(T["parameter_error"]));
            }
            var attributes = _attributeFinder.FindByEntityId(model.EntityId);
            Dictionary <string, Guid> attributeMaps = new Dictionary <string, Guid>(StringComparer.InvariantCultureIgnoreCase);

            foreach (var attr in attributes)
            {
                if (!Request.Form.ContainsKey(attr.Name))
                {
                    continue;
                }

                if (attr.IsSystemControl())
                {
                    continue;
                }

                var mainAttr = Request.Form[attr.Name].ToString();
                attributeMaps.Add(attr.Name, Guid.Parse(mainAttr));
            }
            _dataMerger.Merge(model.EntityId, model.MainRecordId, model.MainRecordId.Equals(model.RecordId1) ? model.RecordId2 : model.RecordId1, attributeMaps);

            return(SaveSuccess());
        }
Example #9
0
        // GET: Bug/Create
        public IActionResult Create()
        {
            MergeModel model = new MergeModel();

            model.Users = UserMgr.Users.ToList();
            return(View(model));
        }
Example #10
0
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Error", "Home"));
            }

            MergeModel model = new MergeModel();

            var bug = await _context.Bugs
                      .FirstOrDefaultAsync(m => m.BugId == id);


            if (bug == null)
            {
                return(RedirectToAction("Error", "Home"));
            }

            var comments = _context.Comments.Where(m => m.BugId == id).ToList();

            model.Bugs     = bug;
            model.Comments = comments;
            model.Users.Add(await UserMgr.FindByIdAsync(bug.AssignedToId.ToString()));
            model.Users.Add(await UserMgr.FindByIdAsync(bug.AssignedById.ToString()));
            model.AppUsers = await UserMgr.GetUserAsync(HttpContext.User);

            return(View(model));
        }
Example #11
0
        public ActionResult Index(int peopleId1, int peopleId2)
        {
            var m = new MergeModel(peopleId1, peopleId2)
            {
                DeleteDuplicate = true
            };

            if (m.pi.Count != 3)
            {
                if (m.pi.Count == 2)
                {
                    if (m.pi[0].PeopleId != peopleId1)
                    {
                        return(Content($"peopleid {peopleId1} not found"));
                    }
                    else
                    {
                        return(Content($"peopleid {peopleId2} not found"));
                    }
                }
                else if (m.pi.Count == 1)
                {
                    return(Content("neither peopleid found"));
                }
            }

            return(View(m));
        }
Example #12
0
        public async Task <IActionResult> EditRole(string id)
        {
            var result = await RoleMgr.FindByIdAsync(id);

            if (result != null)
            {
                var model = new MergeModel
                {
                    RoleId   = result.Id,
                    RoleName = result.Name
                };

                //Collect all users that are associated with the Role Name
                foreach (var user in UserMgr.Users)
                {
                    if (await UserMgr.IsInRoleAsync(user, result.Name))
                    {
                        model.UserNames.Add(user.UserName);
                        model.UserFullNames.Add(user.FirstName + " " + user.LastName);
                    }
                }

                return(View(model));
            }

            return(View());
        }
Example #13
0
        public JsonResult MergeData([FromBody] MergeModel merge_data_file)
        {
            var obj_country_rate = Newtonsoft.Json.JsonConvert.DeserializeObject <List <RateViewModel> >(merge_data_file.country_rate);
            var obj_euro_rates   = Newtonsoft.Json.JsonConvert.DeserializeObject <List <EuroRatesModel> >(merge_data_file.euro_rates);
            List <RateViewModel> merged_rate_lists = common_function.mergeRates(obj_country_rate, obj_euro_rates);

            return(Json(JsonSerializer.Serialize(merged_rate_lists)));
        }
Example #14
0
        public async Task <IActionResult> Create(MergeModel model)
        {
            var assignedBy = UserMgr.GetUserId(HttpContext.User);

            Bug bug = model.Bugs;

            bug.BugCreationTimeStamp = DateTime.Now;
            bug.AssignedById         = Convert.ToInt32(assignedBy);

            _context.Add(bug);
            await _context.SaveChangesAsync();

            var user           = UserMgr.Users.FirstOrDefault(m => m.Id == bug.AssignedToId);
            var userAssignedBy = UserMgr.Users.FirstOrDefault(m => m.Id == bug.AssignedById);
            var role           = await UserMgr.GetRolesAsync(user);

            var roleAssignedBy = await UserMgr.GetRolesAsync(userAssignedBy);

            //check if the user assigned to the bug is already in the bug history model
            var userAssigned = _context.BugAssignmentHistories.FirstOrDefault(m =>
                                                                              m.AssignedToId == bug.AssignedToId && m.BugId == bug.BugId);

            var notification = new Notification
            {
                NotificationType    = NotificationTypeEnum.BugAssigned,
                NotificationMessage = $"Hey {user.FirstName}, you've" +
                                      " been assigned a new Bug by " +
                                      $"({roleAssignedBy[0]}) {userAssignedBy.UserName}!",
                ReceipientId = bug.AssignedToId,
                SenderId     = bug.AssignedById,
                BugId        = bug.BugId
            };

            _context.Add(notification);

            var bugHistory = new BugAssignmentHistory
            {
                BugId        = bug.BugId,
                BugStatus    = bug.BugStatus,
                AssignedToId = bug.AssignedToId,
                RoleName     = role[0]
            };

            if (userAssigned == null)
            {
                _context.Add(bugHistory);
            }
            else
            {
                _context.Update(bugHistory);
            }


            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", "Bug"));
        }
Example #15
0
        public async Task <IActionResult> Login(MergeModel user)
        {
            var result = await SignInMgr.PasswordSignInAsync(user.AppUsers.UserName, user.AppUserPassword, false, false);

            if (result.Succeeded)
            {
                return(RedirectToAction("Index", "Home"));
            }

            return(View());
        }
        private void btn_Merge_Click(object sender, EventArgs e)
        {
            if (!RequiredVerification())
            {
                return;
            }
            if (ShowMessage.ShowConfirm(ChangeLanguage.getLanguage("ConfirmExecution"), showTitle) == DialogResult.OK)
            {
                double            totalSize      = 0;
                FileMergeModel    fileMergeModel = new FileMergeModel();
                List <MergeModel> list           = new List <MergeModel>();
                foreach (ListViewItem item in lv_File.Items)
                {
                    MergeModel model = new MergeModel();
                    model.fileSrc       = item.SubItems[0].Text;
                    model.fileName      = item.SubItems[1].Text;
                    model.fileExtension = item.SubItems[2].Text;
                    model.fileLength    = item.SubItems[3].Text;
                    if (item.Index == lv_File.Items.Count - 1)
                    {
                        model.fileIndex = -1;
                    }
                    else
                    {
                        model.fileIndex = item.Index;
                    }
                    totalSize += double.Parse(model.fileLength);
                    list.Add(model);
                }
                fileMergeModel.mergeFileList      = list;
                fileMergeModel.mergeFilePath      = txt_FilePath.Text;
                fileMergeModel.mergeFileName      = txt_FileName.Text.Trim();
                fileMergeModel.mergeFileExtension = lv_File.Items[0].SubItems[2].Text;
                fileMergeModel.mergeFileSrc       = fileMergeModel.mergeFilePath + @"\" + fileMergeModel.mergeFileName + fileMergeModel.mergeFileExtension;
                if (totalSize > 21474836480)
                {
                    ShowMessage.ShowContent(ChangeLanguage.getLanguage("MergeFileSizeLimit"), showTitle);
                    return;
                }

                if (rbtn_WorkBook.Checked)
                {
                    WorkBookMergeMethodInvoker mergeWorkBookMethod = new WorkBookMergeMethodInvoker(WorkBookMergeMethod);
                    this.BeginInvoke(mergeWorkBookMethod, new object[] { fileMergeModel });
                }
                else if (rbtn_WorkSheet.Checked)
                {
                    WorkSheetMergeMethodInvoker mergeWorkSheetMethod = new WorkSheetMergeMethodInvoker(WorkSheetMergeMethod);
                    this.BeginInvoke(mergeWorkSheetMethod, new object[] { fileMergeModel });
                }
            }
        }
Example #17
0
        public ActionResult filterByName()
        {
            var filteredMemberList = dbCon.Members
                                     .OrderBy(x => x.FirstName).ToList();


            var loanedData = dbCon.Loans.ToList();

            dynamic model = new MergeModel();

            model.Members = filteredMemberList;
            model.Loans   = loanedData;


            return(View(model));
        }
        public MergePageViewModel(
            MergeModel model,
            TfsBranchProvider tfsBranchProvider,
            ChangesetProvider changesetProvider)
        {
            this.changesetProvider = changesetProvider;

            this.Title = "Merge";
            this.Model = model;
            this.BranchDropDownViewModel = new BranchDropDownViewModel(this, tfsBranchProvider);

            ViewPendingChangesCommand = new RelayCommand(NavigateToPendingChangesPage);
            PullCommand = new RelayCommand(Pull);
            PushCommand = new RelayCommand(Push);
            SyncCommand = new RelayCommand(Sync);
        }
Example #19
0
        /// <summary>
        /// This action method takes in the MergeModel object and assigns a new comment that
        /// will be tied to the bug it was added on.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <IActionResult> AddComment(MergeModel model)
        {
            Bug bug = model.Bugs;

            //access logged in user's User record and Role
            var userLoggedInId = Convert.ToInt32(UserMgr.GetUserId(HttpContext.User));
            var currentUser    = await UserMgr.FindByIdAsync(userLoggedInId.ToString());

            var currentUserRole = await UserMgr.GetRolesAsync(currentUser);

            var userAssignedTo = await UserMgr.FindByIdAsync(bug.AssignedToId.ToString());


            /*If the current user is adding a comment to their bug then no need
             * send out a notification.
             */
            if (userLoggedInId != bug.AssignedToId)
            {
                var notification = new Notification
                {
                    NotificationType    = NotificationTypeEnum.NewBugComment,
                    NotificationMessage = $"Hey {userAssignedTo.FirstName}, " +
                                          $"({currentUserRole[0]}) {currentUser.UserName}" +
                                          $" just added a new comment to Bug #{bug.BugId}",
                    ReceipientId = bug.AssignedToId,
                    SenderId     = bug.AssignedById,
                    BugId        = bug.BugId
                };

                _context.Add(notification);
            }


            var comments = new Comment
            {
                CommentText = model.Comment.CommentText,
                BugId       = bug.BugId,
                UserId      = userLoggedInId
            };

            _context.Add(comments);


            await _context.SaveChangesAsync();

            return(RedirectToAction("Details", "Bug", new { id = bug.BugId }));
        }
        public ActionResult Run(string submit, bool?Delete, MergeModel m)
        {
            var mh = new MergeHistory
            {
                FromId   = m.pi[0].PeopleId,
                ToId     = m.pi[1].PeopleId,
                FromName = m.pi[0].person.Name,
                ToName   = m.pi[1].person.Name,
                WhoId    = Util.UserPeopleId,
                WhoName  = Util.UserFullName,
                Action   = submit + (Delete == true ? " + Delete" : ""),
                Dt       = DateTime.Now,
            };

            DbUtil.Db.MergeHistories.InsertOnSubmit(mh);
            if (submit.StartsWith("Merge Fields"))
            {
                DbUtil.LogActivity("Merging Fields from {0} to {1}".Fmt(m.pi[0].PeopleId, m.pi[1].PeopleId));
                m.Update();
            }
            if (submit == "Merge Fields and Move Related Records")
            {
                DbUtil.LogActivity("Moving records from {0} to {1}".Fmt(m.pi[0].PeopleId, m.pi[1].PeopleId));
                m.Move();
                if (Delete == true)
                {
                    DbUtil.LogActivity("Deleting Record during Merge {0} to {1}".Fmt(m.pi[0].PeopleId, m.pi[1].PeopleId));
                    m.Delete();
                }
            }
            if (submit == "Toggle Not Duplicate")
            {
                if (m.pi[0].notdup || m.pi[1].notdup)
                {
                    var dups = DbUtil.Db.PeopleExtras.Where(ee => ee.Field == "notdup" && (ee.PeopleId == m.pi[0].PeopleId || ee.PeopleId == m.pi[1].PeopleId));
                    DbUtil.Db.PeopleExtras.DeleteAllOnSubmit(dups);
                }
                else
                {
                    m.pi[0].person.AddEditExtraInt("notdup", m.pi[1].PeopleId);
                    m.pi[1].person.AddEditExtraInt("notdup", m.pi[0].PeopleId);
                }
                DbUtil.Db.SubmitChanges();
                return(Redirect("/Merge/{0}/{1}".Fmt(m.pi[0].PeopleId, m.pi[1].PeopleId)));
            }
            return(Redirect("/Person2/" + m.pi[1].PeopleId));
        }
Example #21
0
        public IActionResult Merge(Guid entityid, Guid recordid1, Guid recordid2)
        {
            MergeModel model = new MergeModel();

            if (entityid.Equals(Guid.Empty) || recordid1.Equals(Guid.Empty) || recordid2.Equals(Guid.Empty))
            {
                return(JError(T["parameter_error"]));
            }
            model.EntityMetas = _entityFinder.FindById(entityid);
            model.Attributes  = _attributeFinder.FindByEntityId(entityid);
            model.Record1     = _dataFinder.RetrieveById(model.EntityMetas.Name, recordid1);
            model.Record2     = _dataFinder.RetrieveById(model.EntityMetas.Name, recordid2);
            model.EntityId    = entityid;
            model.RecordId1   = recordid1;
            model.RecordId2   = recordid2;
            return(View($"~/Views/Entity/{WebContext.ActionName}.cshtml", model));
        }
        private void Merge(Collection <int> ids, string link)
        {
            MergeModel model = ModelFactory.GetMergeModel(ids, this.Book, this.SubBook);

            if (model.View == null)
            {
                return;
            }

            if (model.View.Count.Equals(0))
            {
                return;
            }

            HttpContext.Current.Session["Product"] = model;
            HttpContext.Current.Response.Redirect(link);
        }
Example #23
0
        public async Task <IActionResult> CreateRole(MergeModel modelRole)
        {
            AppRole role = new AppRole
            {
                Name = modelRole.RoleName
            };

            IdentityResult result = await RoleMgr.CreateAsync(role);

            if (result.Succeeded)
            {
                return(RedirectToAction("Index", "Admin"));
            }


            return(View());
        }
Example #24
0
        public async Task <IActionResult> EditRole(MergeModel mergeModel)
        {
            var role = await RoleMgr.FindByIdAsync(mergeModel.RoleId.ToString());

            if (role != null)
            {
                role.Name = mergeModel.RoleName;
                var result = await RoleMgr.UpdateAsync(role);

                if (result.Succeeded)
                {
                    return(RedirectToAction("Index", "Admin"));
                }
            }

            return(View(mergeModel));
        }
Example #25
0
 public void SetModel(MergeModel model, Application application, Order order)
 {
     model.Time        = application.Time;
     model.GNIBNo      = model.GNIBNo ?? application.GNIBNo;
     model.GNIBExDT    = model.GNIBExDT ?? application.GNIBExDT;
     model.Salutation  = model.Salutation ?? application.Salutation;
     model.GivenName   = model.GivenName ?? application.GivenName;
     model.MidName     = model.MidName ?? application.MidName;
     model.SurName     = model.SurName ?? application.SurName;
     model.DOB         = model.DOB ?? application.DOB;
     model.Nationality = model.Nationality ?? application.Nationality;
     model.Email       = model.Email ?? application.Email;
     model.FamAppYN    = model.FamAppYN ?? application.FamAppYN;
     model.FamAppNo    = model.FamAppNo ?? application.FamAppNo;
     model.PPNoYN      = model.PPNoYN ?? application.PPNoYN;
     model.PPNo        = model.PPNo ?? application.PPNo;
     model.PPReason    = model.PPReason ?? application.PPReason;
     model.Comment     = model.Comment ?? application.Comment;
 }
        public MergeViewModel()
        {
            Model = new MergeModel();

            Model.BrowseCommand           = new RelayCommand <object>(BrowseExecute);
            Model.BrowseOutputFileCommand = new RelayCommand <object>(BrowseOutputExecute);
            Model.MergeCommand            = new RelayCommand <object>(MergeExecute);

            var path = "../";

#if DEBUG
            path = "../../../";
#endif

            var i18nFolder = new Uri(new Uri(AppDomain.CurrentDomain.BaseDirectory), path).LocalPath;
            Model.OutputFile = io::Path.Combine(i18nFolder, "jquery.formatCurrency.all.js");

            // I'm changing the InputFolder shortly so I'll call LoadFiles in a second.
            Model.InputFolderChanged += (s, e) => LoadFiles();
            Model.InputFolder         = i18nFolder;
        }
Example #27
0
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Error", "Home"));
            }

            var bug = await _context.Bugs
                      .FirstOrDefaultAsync(m => m.BugId == id);

            if (bug == null)
            {
                return(RedirectToAction("Error", "Home"));
            }

            MergeModel model = new MergeModel();

            model.Bugs = bug;
            model.Users.Add(await UserMgr.FindByIdAsync(bug.AssignedToId.ToString()));
            model.Users.Add(await UserMgr.FindByIdAsync(bug.AssignedById.ToString()));

            return(View(model));
        }
Example #28
0
        public async Task <IActionResult> Merge(MergeModel model)
        {
            if (model.Save)
            {
                throw new NotImplementedException();
            }
            else
            {
                var applicationManager = DomainHub.GetDomain <IApplicationManager>();

                var application     = applicationManager[model.Id];
                var order           = applicationManager.GetOrder(model.Id);
                var withApplication = applicationManager[model.WithId];
                var withOrder       = applicationManager.GetOrder(model.WithId);

                SetModel(model, application, order);

                var merging = new MergeModel();
                SetModel(merging, withApplication, withOrder);
                ViewBag.Merging = merging;

                return(View(model));
            }
        }
        public ActionResult Index(int PeopleId1, int PeopleId2)
        {
            var m = new MergeModel(PeopleId1, PeopleId2);

            if (m.pi.Count != 3)
            {
                if (m.pi.Count == 2)
                {
                    if (m.pi[0].PeopleId != PeopleId1)
                    {
                        return(Content("peopleid {0} not found".Fmt(PeopleId1)));
                    }
                    else
                    {
                        return(Content("peopleid {0} not found".Fmt(PeopleId2)));
                    }
                }
                else if (m.pi.Count == 1)
                {
                    return(Content("neither peopleid found"));
                }
            }
            return(View(m));
        }
Example #30
0
        private void LoadValuesFromSession()
        {
            if (this.Session["Product"] == null)
            {
                return;
            }

            this.model = this.Session["Product"] as MergeModel;

            if (this.model == null)
            {
                return;
            }

            this.PartyCodeHidden.Value = this.model.PartyCode.ToString(LocalizationHelper.GetCurrentCulture());
            this.PartyCodeTextBox.Text = this.model.PartyCode.ToString(LocalizationHelper.GetCurrentCulture());
            this.PriceTypeIdHidden.Value = this.model.PriceTypeId.ToString(SessionHelper.GetCulture());

            this.ReferenceNumberTextBox.Text = this.model.ReferenceNumber;
            this.StatementReferenceTextBox.Text = this.model.StatementReference;

            this.Session[this.ID] = this.model.View;
            TranIdCollectionHiddenField.Value = string.Join(",", this.model.TransactionIdCollection);
            this.ClearSession("Product");
        }
Example #31
0
        public static MergeModel GetMergeModel(Collection<int> ids, TranBook book, SubTranBook subBook)
        {
            int rowIndex = 0;

            if (ids == null)
            {
                return new MergeModel();
            }

            if (ids.Count.Equals(0))
            {
                return new MergeModel();
            }

            MergeModel model = new MergeModel();

            foreach (int tranId in ids)
            {
                model.AddTransactionIdToCollection(tranId);
            }

            model.Book = book;
            model.SubBook = subBook;

            using (NpgsqlConnection connection = new NpgsqlConnection(DbConnection.ConnectionString()))
            {
                using (NpgsqlCommand command = SalesQuotation.GetSalesQuotationViewCommand(ids))
                {
                    command.Connection = connection;
                    command.Connection.Open();
                    NpgsqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);

                    if (!reader.HasRows)
                    {
                        return new MergeModel();
                    }

                    while (reader.Read())
                    {
                        if (rowIndex.Equals(0))
                        {
                            model.ValueDate = Conversion.TryCastDate(reader["value_date"]);
                            model.PartyCode = Conversion.TryCastString(reader["party_code"]);
                            model.PriceTypeId = Conversion.TryCastInteger(reader["price_type_id"]);
                            model.ReferenceNumber = Conversion.TryCastString(reader["reference_number"]);
                            model.StatementReference = Conversion.TryCastString(reader["statement_reference"]);
                        }

                        ProductDetailsModel product = new ProductDetailsModel();

                        product.ItemCode = Conversion.TryCastString(reader["item_code"]);
                        product.ItemName = Conversion.TryCastString(reader["item_name"]);
                        product.Unit = Conversion.TryCastString(reader["unit_name"]);

                        product.Quantity = Conversion.TryCastInteger(reader["quantity"]);
                        product.Price = Conversion.TryCastDecimal(reader["price"]);
                        product.Amount = product.Quantity * product.Price;

                        product.Discount = Conversion.TryCastDecimal(reader["discount"]);
                        product.Subtotal = product.Amount - product.Discount;

                        product.Rate = Conversion.TryCastDecimal(reader["tax_rate"]);
                        product.Tax = Conversion.TryCastDecimal(reader["tax"]);
                        product.Total = product.Subtotal + product.Tax;

                        model.AddViewToCollection(product);

                        rowIndex++;
                    }
                }
            }

            if (ids.Count > 0)
            {
                if (!string.IsNullOrWhiteSpace(model.StatementReference))
                {
                    model.StatementReference += Environment.NewLine;
                }

                model.StatementReference += "(" + Conversion.GetBookAcronym(book, subBook) + "# " + string.Join(",", ids) + ")";
            }

            return model;
        }
Example #32
0
        public static MergeModel GetMergeModel(string catalog, Collection <long> ids, TranBook tranBook, SubTranBook subTranBook)
        {
            int rowIndex = 0;

            if (ids == null)
            {
                return(new MergeModel());
            }

            if (ids.Count.Equals(0))
            {
                return(new MergeModel());
            }

            MergeModel model = new MergeModel();

            foreach (long tranId in ids)
            {
                model.AddTransactionIdToCollection(tranId);
            }

            model.Book    = tranBook;
            model.SubBook = subTranBook;

            using (NpgsqlConnection connection = new NpgsqlConnection(DbConnection.GetConnectionString(catalog)))
            {
                using (NpgsqlCommand command = GetViewCommand(tranBook, subTranBook, ids))
                {
                    command.Connection = connection;
                    command.Connection.Open();
                    NpgsqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);

                    if (!reader.HasRows)
                    {
                        return(new MergeModel());
                    }

                    while (reader.Read())
                    {
                        if (rowIndex.Equals(0))
                        {
                            model.ValueDate           = Conversion.TryCastDate(reader["value_date"]);
                            model.PartyCode           = Conversion.TryCastString(reader["party_code"]);
                            model.PriceTypeId         = Conversion.TryCastInteger(reader["price_type_id"]);
                            model.ReferenceNumber     = Conversion.TryCastString(reader["reference_number"]);
                            model.NonTaxableSales     = Conversion.TryCastBoolean(reader["non_taxable"]);
                            model.ShippingCompanyId   = Conversion.TryCastInteger(reader["shipper_id"]);
                            model.SalesPersonId       = Conversion.TryCastInteger(reader["salesperson_id"]);
                            model.StoreId             = Conversion.TryCastInteger(reader["store_id"]);
                            model.ShippingAddressCode = Conversion.TryCastString(reader["shipping_address_code"]);
                            model.StatementReference  = Conversion.TryCastString(reader["statement_reference"]);
                        }

                        ProductDetail product = new ProductDetail();

                        product.ItemCode = Conversion.TryCastString(reader["item_code"]);
                        product.ItemName = Conversion.TryCastString(reader["item_name"]);
                        product.Unit     = Conversion.TryCastString(reader["unit_name"]);

                        product.Quantity = Conversion.TryCastInteger(reader["quantity"]);
                        product.Price    = Conversion.TryCastDecimal(reader["price"]);
                        product.Amount   = product.Quantity * product.Price;

                        product.Discount       = Conversion.TryCastDecimal(reader["discount"]);
                        product.ShippingCharge = Conversion.TryCastDecimal(reader["shipping_charge"]);
                        product.Subtotal       = product.Amount - product.Discount - product.ShippingCharge;

                        product.TaxCode = Conversion.TryCastString(reader["tax_code"]);
                        product.Tax     = Conversion.TryCastDecimal(reader["tax"]);
                        product.Total   = product.Subtotal + product.Tax;

                        model.AddViewToCollection(product);

                        rowIndex++;
                    }
                }
            }

            if (ids.Count > 0)
            {
                if (!string.IsNullOrWhiteSpace(model.StatementReference))
                {
                    model.StatementReference += Environment.NewLine;
                }

                model.StatementReference += "(" +
                                            Entities.Helpers.TransactionBookHelper.GetBookAcronym(tranBook, subTranBook) +
                                            "# " + string.Join(",", ids) + ")";
            }

            return(model);
        }
        private void LoadValuesFromSession()
        {
            if (this.Session["Product"] == null)
            {
                return;
            }

            this.model = this.Session["Product"] as MergeModel;

            if (this.model == null)
            {
                return;
            }

            this.PartyDropDownList.SelectedValue = this.model.PartyCode.ToString(LocalizationHelper.GetCurrentCulture());
            this.PartyCodeTextBox.Text = this.model.PartyCode.ToString(LocalizationHelper.GetCurrentCulture());

            if (this.PriceTypeDropDownList.SelectedItem != null)
            {
                DropDownListHelper.SetSelectedValue(this.PriceTypeDropDownList, this.model.PriceTypeId.ToString(SessionHelper.GetCulture()));
            }

            this.ReferenceNumberTextBox.Text = this.model.ReferenceNumber;
            this.StatementReferenceTextBox.Text = this.model.StatementReference;

            this.Session[this.ID] = this.model.View;
            this.Session["TranIdCollection"] = this.model.TransactionIdCollection;
            this.ClearSession("Product");
        }