Exemple #1
0
        public string SaveOrganisation(string Organisation,
                                       string Email,
                                       string Contact,
                                       string line1,
                                       string line2,
                                       string line3,
                                       string line4,
                                       string line5,
                                       string Code)
        {
            // save the Organisation details to the database
            string          OpperationStatus = "";
            var             user             = _userManager.GetUserAsync(User).Result;
            TblOrganisation Org = new TblOrganisation();

            Org.ID = Guid.NewGuid();
            Org.ApplicationUserId = user.Id;
            Org.Name         = Organisation;
            Org.ContactEmail = Email;
            Org.Contact      = Contact;
            Org.Address      = line1 + "\n" + line2 + "\n" + line3 + "\n" + line4 + "\n" + line5 + "\n" + Code;

            _context.Organisations.Add(Org);
            try
            {
                _context.SaveChanges();
                OpperationStatus = Org.ID.ToString();
            }
            catch
            {
                OpperationStatus = "Failure";
            }
            return(OpperationStatus);
        }
Exemple #2
0
 public void ToTableModel(TblOrganisation ToReturn, OrganisationViewModel Model)
 {
     ToReturn.Name         = Model.Name;
     ToReturn.Address      = Model.Address;
     ToReturn.Contact      = Model.Contact;
     ToReturn.ContactEmail = Model.ContactEmail;
     ToReturn.ContactNo    = Model.ContactNo;
 }
Exemple #3
0
        public OrganisationViewModel ToViewModel(TblOrganisation Model)
        {
            OrganisationViewModel ToReturn = new OrganisationViewModel();

            ToReturn.Address      = Model.Address;
            ToReturn.Contact      = Model.Contact;
            ToReturn.ContactEmail = Model.ContactEmail;
            ToReturn.ContactNo    = Model.ContactNo;
            ToReturn.Name         = Model.Name;
            return(ToReturn);
        }
Exemple #4
0
        public TblOrganisation NewOrg(ApplicationUser AU)
        {
            TblOrganisation ToReturn = new TblOrganisation();

            ToReturn.ApplicationUser = AU;
            ToReturn.Address         = "This is a new Org address";
            ToReturn.Contact         = " Mr AN Other1";
            ToReturn.ContactEmail    = "*****@*****.**";
            ToReturn.ContactNo       = "01010 010100101010";
            ToReturn.Name            = "New Org one X";
            return(ToReturn);
        }
        public async Task <IActionResult> Create([Bind("Name,Contact,ContactEmail,ContactNo,Address,ApplicationUserId")] OrganisationViewModel FromView)
        {
            if (ModelState.IsValid)
            {
                FromView.Id = Guid.NewGuid().ToString();
                TblOrganisation result = OrgDTO.ToTableModel(FromView);
                _context.Organisations.Add(result);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(FromView));
        }
Exemple #6
0
        public TblOrganisation ToTableModel(OrganisationViewModel Model)
        {
            TblOrganisation ToReturn = new TblOrganisation();

            ToReturn.ID = Guid.Parse(Model.Id);
            ToReturn.ApplicationUserId = Guid.Parse(Model.ApplicationUserId);
            ToReturn.Name         = Model.Name;
            ToReturn.Address      = Model.Address;
            ToReturn.Contact      = Model.Contact;
            ToReturn.ContactEmail = Model.ContactEmail;
            ToReturn.ContactNo    = Model.ContactNo;
            return(ToReturn);
        }
Exemple #7
0
        public OrganisationItemIndexViewModel ToIndexModel(TblOrganisation FromDB)
        {
            OrganisationItemIndexViewModel ToReturn = new OrganisationItemIndexViewModel();

            ToReturn.OrganisationId   = FromDB.ID.ToString();
            ToReturn.OrganisationName = FromDB.Name;
            foreach (var line in FromDB.Items)
            {
                ToReturn.Index.Add(new OrganisationItemIndexItemViewModel()
                {
                    Id   = line.ID.ToString(),
                    Name = line.Name,
                    Code = line.Code
                });
            }
            return(ToReturn);
        }
Exemple #8
0
        public PurchaseOrderViewModel ToViewModel(TblPurchaseOrder Model, List <string> BudgetCodes, List <OrgDetail> Organisations, TblOrganisation OrgItems)
        {
            PurchaseOrderViewModel ToReturn = new PurchaseOrderViewModel();

            ToReturn.ApplicationUserId = Model.ApplicationUser.Id.ToString();
            ToReturn.Budget            = Model.Budget;
            ToReturn.BudgetCodes       = BudgetCodes;
            ToReturn.Code             = Model.Code;
            ToReturn.DateFullfilled   = Model.DateFullfilled;
            ToReturn.DateRaised       = Model.DateRaised;
            ToReturn.DateRequired     = Model.DateRequired;
            ToReturn.DeliverTo        = Model.DeliverTo;
            ToReturn.DeliverToDetail  = Model.DeliverToDetail;
            ToReturn.DeliverToOptions = Organisations;
            ToReturn.Id               = Model.ID.ToString();
            ToReturn.InvoiceTo        = Model.InvoiceTo;
            ToReturn.InvoiceToDetail  = Model.InvoiceToDetail;
            ToReturn.InvoiceToOptions = Organisations;
            ToReturn.Note             = Model.Note;
            ToReturn.Price            = Model.Price;
            ToReturn.RowVersionNo     = Model.RowVersionNo;
            ToReturn.Status           = Model.Status;
            ToReturn.Tax              = Model.Tax;
            ToReturn.To               = Model.To;
            ToReturn.ToDetail         = Model.ToDetail;
            ToReturn.ToOptions        = Organisations;
            ToReturn.Total            = Model.Total;
            ToReturn.HTMLSelectOrganisationItems.Add(new SelectOrgItem()
            {
                Text     = "Select Item",
                Value    = "SelectItem",
                Selected = true
            });
            ToReturn.HTMLSelectOrganisationItems.Add(new SelectOrgItem()
            {
                Text     = "New Item",
                Value    = "NewItem",
                Selected = true
            });

            if (OrgItems != null)
            {
                foreach (var I in OrgItems.Items)
                {
                    ToReturn.HTMLSelectOrganisationItems.Add(new SelectOrgItem()
                    {
                        Text     = I.Code,
                        Value    = I.ID.ToString(),
                        Selected = false
                    });
                }
            }



            //if (OrgItems != null)
            //{
            //    foreach (var I in OrgItems.Items)
            //    {
            //        ToReturn.HTMLSelectOrganisationItems.Add(new SelectOrgItem()
            //        {
            //             Text = I.Name,
            //             Value = I.ID.ToString()
            //        });
            //    }
            //}
            if (Model.Items != null)
            {
                foreach (var I in Model.Items)
                {
                    ToReturn.Items.Add(new PurchaseOrderItemViewModel()
                    {
                        Brand       = I.Brand,
                        Code        = I.Code,
                        Description = I.Description,
                        Id          = I.ID.ToString(),
                        Name        = I.Name,
                        Price       = I.Price,
                        Quantity    = I.Quantity,
                        RowVersion  = I.RowVersionNo,
                        Tax         = I.Tax,
                        TaxCode     = I.TaxCode,
                        Total       = I.Total
                    });
                }
            }
            return(ToReturn);
        }