Exemplo n.º 1
0
 public AgencyRepository(IConnection <Core.Model.Agency.Agency> iAgencyConnection,
                         IConnection <Core.Model.Agency.AgencyContacts> iAgencyContacts,
                         IConnection <Core.Model.Agency.IncludedCountryRelation> iAgencyIncludedCountry,
                         IConnection <Core.Model.Agency.ExcludedCountryRelation> iAgencyExcludedCountry,
                         IConnection <Core.Model.Agency.Payment> iAgencyPayment,
                         IConnection <Core.Model.Agency.Bank> iAgencyBank,
                         IConnection <Core.Model.Agency.AgencySupplierRelation> iAgencySupplier,
                         IConnection <Core.Model.Agency.Agents> iAgencySuperUser,
                         IConnection <Core.Model.Agency.Branch> iAgencyBranch,
                         IConnection <Core.Model.Agency.BranchAgentRelation> iBranchAgentRelation,
                         IConnection <Currency> iCurrency,
                         IConnection <Country> iCountry)
 {
     this.iAgency                        = iAgencyConnection;
     this.iAgencyContact                 = iAgencyContacts;
     this.iAgencyIncludedCountry         = iAgencyIncludedCountry;
     this.iAgencyExcludedCountry         = iAgencyExcludedCountry;
     this.iAgencySupplierRelation        = iAgencySupplier;
     this.iAgencyBank                    = iAgencyBank;
     this.iAgencyPayment                 = iAgencyPayment;
     this.iAgencySuperUser               = iAgencySuperUser;
     this.iAgencyBranch                  = iAgencyBranch;
     this.iAgencyBranchAgentRelation     = iBranchAgentRelation;
     this.iCurrency                      = iCurrency;
     this.ClassName                      = "AgencyRepository";
     this.agencyViewModel                = new AgencyViewModel();
     this.agencyIncludedCountryViewModel = new AgencyIncludedCountry();
     this.agencyExcludedCountryViewModel = new AgencyExcludedCountry();
     this.iCountry                       = iCountry;
 }
        public AgencyResponse Create(AgencyViewModel Agency)
        {
            AgencyResponse response = new AgencyResponse();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();

                SqliteCommand insertCommand = db.CreateCommand();
                insertCommand.CommandText = SqlCommandInsertPart;

                try
                {
                    insertCommand = AddCreateParameters(insertCommand, Agency);
                    insertCommand.ExecuteNonQuery();
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage = error.Message;
                    response.Success        = false;
                    response.Message        = error.Message;
                    return(response);
                }
                db.Close();

                response.Success = true;
                return(response);
            }
        }
Exemplo n.º 3
0
        public ActionResult AgencyManager()
        {
            var vm = new AgencyViewModel();

            vm.HandleRequest();
            return(View(vm));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Member(AgencyViewModel model)
        {
            if (ModelState.IsValid)
            {
                var currentUser = await _userContext.GetCurrentUser();

                var currentCustomerGroup = await _userContext.GetCustomerGroup();

                if (currentCustomerGroup == CustomerGroup.Agency)
                {
                    var command = _mapper.Map <AgencyViewModel, AgencyConfirmationCommand>(model);
                    command.UserConfirmation = currentUser;
                    await _processor.ProcessCommandAsync <AgencyConfirmationCommand>(command);
                }
                else
                {
                    if (currentCustomerGroup == CustomerGroup.Customer)
                    {
                        var command = _mapper.Map <AgencyViewModel, CustomerConfirmationCommand>(model);
                        command.UserConfirmation = currentUser;
                        await _processor.ProcessCommandAsync <CustomerConfirmationCommand>(command);
                    }
                }
                if (!string.IsNullOrEmpty(model.Password?.Trim()))
                {
                    await _userContext.ChangePassword(model.Password.Trim(), currentUser);
                }
                return(GetShoppingPageToRedirect());
            }
            return(View(model));
        }
Exemplo n.º 5
0
        public static AgencyViewModel ConvertToAgencyViewModel(this Agency Agency)
        {
            AgencyViewModel AgencyViewModel = new AgencyViewModel()
            {
                Id         = Agency.Id,
                Identifier = Agency.Identifier,

                Code         = Agency.Code,
                InternalCode = Agency.InternalCode,
                Name         = Agency.Name,

                Country = Agency.Country?.ConvertToCountryViewModelLite(),
                Sector  = Agency.Sector?.ConvertToSectorViewModelLite(),

                IsActive = Agency.Active,

                CreatedBy = Agency.CreatedBy?.ConvertToUserViewModelLite(),
                Company   = Agency.Company?.ConvertToCompanyViewModelLite(),

                UpdatedAt = Agency.UpdatedAt,
                CreatedAt = Agency.CreatedAt
            };

            return(AgencyViewModel);
        }
Exemplo n.º 6
0
        public IActionResult Index()
        {
            AgencyViewModel data = new AgencyViewModel
            {
                Agencies = new AgencyIndexViewModel
                {
                    Users = _context.Users.Include("Adds").Where(u => u.UserTypeID == 1 && u.Status == UserStatus.Active && u.Adds.Count() > 0).ToList(),
                },
                Breadcumb = new BreadcumbViewModel
                {
                    Title = "Agentliklər",
                    Path  = new List <BreadcumbItemViewModel>()
                },
            };
            BreadcumbItemViewModel home = new BreadcumbItemViewModel
            {
                Name       = "Ana səhifə",
                Controller = "Home",
                Action     = "index"
            };
            BreadcumbItemViewModel Agencies = new BreadcumbItemViewModel
            {
                Name = "Agentliklər"
            };

            data.Breadcumb.Path.Add(home);
            data.Breadcumb.Path.Add(Agencies);
            ViewBag.Partial = data.Breadcumb;
            return(View(data));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Detail(AgencyViewModel model)
        {
            await _IAgencyBusiness.UpdateAgency(model);

            TempData["MessageSuccess"] = "Update thành công!";
            return(Redirect("/agency/detail/?id=" + model.Id));
        }
Exemplo n.º 8
0
        public JsonResult Gets()
        {
            //var list = new List<LicenseClass>();
            try
            {
                //var list = db.Agencies.Where(x=>x.Enable==true).ToList();
                List <AgencyViewModel> list = new List <AgencyViewModel>();

                foreach (var item in db.Agencies.Where(x => x.Enable == true).ToList())
                {
                    AgencyViewModel agencyViewModel = new AgencyViewModel
                    {
                        Id = item.Id,
                        FechaHabilitacion = item.FechaHabilitacion?.ToString("dd/MM/yyyy"),
                        Nombre            = item.Nombre,
                        NroAgencia        = item.NroAgencia
                    };

                    list.Add(agencyViewModel);
                }

                return(Json(list, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 9
0
        public JsonResult Get(int id)
        {
            Agency model = new Agency();

            try
            {
                model = db.Agencies.Find(id);

                AgencyViewModel agencyViewModel = new AgencyViewModel
                {
                    Id = model.Id,
                    FechaHabilitacion = model.FechaHabilitacion?.ToString("dd/MM/yyyy"),
                    Nombre            = model.Nombre,
                    NroAgencia        = model.NroAgencia
                };



                return(Json(agencyViewModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 10
0
        private static void OnCurrentAgencyPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            AgencyPopup     popup  = source as AgencyPopup;
            AgencyViewModel agency = (AgencyViewModel)e.NewValue;

            popup.txtAgency.Text = agency != null ? agency.Code + " (" + agency.Name + ")" : "";
        }
Exemplo n.º 11
0
        public static void AddAgency(AgencyViewModel avm)
        {
            Agency agency = AgencyViewModelToAgency(avm);

            using (OpidDailyDB opiddailycontext = new OpidDailyDB())
            {
                opiddailycontext.Agencies.Add(agency);
                opiddailycontext.SaveChanges();
            }
        }
Exemplo n.º 12
0
        private static void CreateXmlFile(AgencyViewModel agencyViewModel)
        {
            XmlSerializer formatter = new XmlSerializer(typeof(AgencyViewModel));
            string        fileName  = String.Format("{0}{1}.xml", xmlFolderPath, agencyViewModel.Name);

            using (FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate))
            {
                formatter.Serialize(fs, agencyViewModel);
            }
        }
Exemplo n.º 13
0
        public static void DeleteAgency(AgencyViewModel avm)
        {
            using (OpidDailyDB opiddailycontext = new OpidDailyDB())
            {
                Agency agency = opiddailycontext.Agencies.Find(avm.Id);

                opiddailycontext.Agencies.Remove(agency);

                opiddailycontext.SaveChanges();
            }
        }
Exemplo n.º 14
0
        public async Task <ActionResult> RegisterAgency(AgencyViewModel model, HttpPostedFileBase pimage, HttpPostedFileBase timage)
        {
            if (ModelState.IsValid)
            {
                string pimg = "";
                string timg = "";
                if (pimage != null)
                {
                    pimg = Guid.NewGuid() + System.IO.Path.GetFileName(pimage.FileName);
                    /*Saving the file in server folder*/
                    pimage.SaveAs(Server.MapPath("~/Images/Profile/" + pimg));
                }
                else
                {
                    pimg = "ProfileImage.jpg";
                }
                if (timage != null)
                {
                    timg = Guid.NewGuid() + System.IO.Path.GetFileName(timage.FileName);
                    /*Saving the file in server folder*/
                    timage.SaveAs(Server.MapPath("~/Images/Agency/" + timg));
                }
                else
                {
                    timg = "AgencyImage.png";
                }
                //Save Agency In Database
                Agency ag = new Agency()
                {
                    Title       = model.Title,
                    Description = model.Description,
                    Email       = model.Email,
                    Facebook    = model.Facebook,
                    Image       = timg,
                    Instagram   = model.Instagram,
                    Mobile      = model.Mobile,
                    Skype       = model.Skype,
                    Twitter     = model.Twitter
                };
                db.Agency.Add(ag);
                db.SaveChanges();
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email, Phone = model.Mobile, Skype = model.Skype, Twitter = model.Twitter, Instagram = model.Instagram, FirstName = model.FirstName, LastName = model.LastName, PhoneNumber = model.Mobile, ProfileImage = pimg, IsAgencyAdmin = true, AgencyId = db.Agency.FirstOrDefault(x => x.Email == model.Email).Id
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    return(RedirectToAction("Login", "Account", new { returnUrl = "Home/Index" }));
                }
                AddErrors(result);
            }
            return(View(model));
        }
Exemplo n.º 15
0
        // Add Agency : Get
        public ActionResult Add(int p = 1, int ps = 50)
        {
            StorePaging(p, ps);

            var model = new AgencyViewModel();

            model.PageNum  = PageNumber;
            model.PageSize = PageSize;

            return(View(model));
        }
Exemplo n.º 16
0
        public ActionResult Update(AgencyViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            _agencyService.AddOrUpdate(model);

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 17
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            AgencyViewModel Agency = new AgencyViewModel();

            Agency.Identifier = Guid.NewGuid();

            AgencyAddEdit addEditForm = new AgencyAddEdit(Agency, true);

            addEditForm.AgencyCreatedUpdated += new AgencyHandler(SyncData);
            FlyoutHelper.OpenFlyout(this, ((string)Application.Current.FindResource("Delatnosti")), 95, addEditForm);
        }
 public IActionResult Update([FromBody] AgencyViewModel agencyVm)
 {
     if (!ModelState.IsValid)
     {
         IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors);
         return(new BadRequestObjectResult(allErrors));
     }
     _agencyService.Update(agencyVm);
     _agencyService.SaveChanges();
     return(new OkObjectResult(agencyVm));
 }
Exemplo n.º 19
0
        public async Task UpdateAgency(AgencyViewModel model)
        {
            var agency = await _IAgencyRepository.GetByIdAsync(model.Id);

            agency.Name        = model.Name;
            agency.Email       = model.Email;
            agency.Address     = model.Address;
            agency.TaxIdNumber = model.TaxNumber;
            agency.Phone       = model.Phone;
            agency.Actived     = model.Actived;
            await _IAgencyRepository.UpdateAsync(agency);
        }
Exemplo n.º 20
0
 private static Agency AgencyViewModelToAgency(AgencyViewModel avm)
 {
     return(new Agency
     {
         AgencyId = avm.AgencyId,
         AgencyName = avm.AgencyName,
         ContactPerson = avm.ContactPerson,
         Phone = avm.Phone,
         Email = avm.Email,
         IsActive = (avm.IsActive == "Yes" ? true : false)
     });
 }
        public AgencyAddEdit(AgencyViewModel AgencyViewModel, bool isCreateProcess, bool isPopup = false)
        {
            AgencyService = DependencyResolver.Kernel.Get <IAgencyService>();

            // Initialize form components
            InitializeComponent();

            this.DataContext = this;

            CurrentAgency   = AgencyViewModel;
            IsCreateProcess = isCreateProcess;
            IsPopup         = isPopup;
        }
Exemplo n.º 22
0
        /// <summary>
        /// Gets agency view model by id.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public AgencyViewModel Get(int id)
        {
            var agencyViewModel = new AgencyViewModel();

            var agency = _agencyRepo.Get(id);

            if (agency != null)
            {
                agencyViewModel = _mapper.Map <AgencyViewModel>(agency);
            }

            return(agencyViewModel);
        }
Exemplo n.º 23
0
        public void AddOrUpdate(AgencyViewModel agencyViewModel)
        {
            var agency = _mapper.Map <Agency>(agencyViewModel);

            if (agency.Id == 0)
            {
                _agencyRepo.Add(agency);
            }
            else
            {
                _agencyRepo.Update(agency);
            }
        }
Exemplo n.º 24
0
        public async Task <IActionResult> CreateAsync(AgencyViewModel agencyViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("Create", agencyViewModel));
            }

            var createAgencyCommand = _mapper.Map <AgencyViewModel, CreateAgencyCommand>(agencyViewModel);

            await _mediator.Send(createAgencyCommand);

            return(RedirectToAction(nameof(GetAllAsync)));
        }
Exemplo n.º 25
0
        public async Task <IActionResult> Member()
        {
            var currentUser = await _userContext.GetCurrentUser();

            var currentCustomerGroup = await _userContext.GetCustomerGroup();

            AgencyViewModel model = new AgencyViewModel()
            {
                Title = nameof(Member)
            };

            if (currentCustomerGroup == CustomerGroup.Agency)
            {
                var response = await _processor.ProcessQueryAsync <OrganisationQuery, OrganisationResponse>(new OrganisationQuery()
                {
                    NameOrId = currentUser.Email
                });

                var organisation = response.Organisations.FirstOrDefault();
                if (organisation == null)
                {
                    PopulateErrorMessage("Not found any organisation match your account.");
                }
                else
                {
                    model = _mapper.Map <Livis.Market.Data.Organisation, AgencyViewModel>(organisation);
                    model.CustomerGroup = CustomerGroup.Agency;
                    PopulateErrorMessage(string.Empty);
                }
            }
            else
            {
                if (currentCustomerGroup == CustomerGroup.Customer)
                {
                    var response = await _processor.ProcessQueryAsync <ContactQuery, ContactResponse>(new ContactQuery { OwnerId = currentUser.Id });

                    model.FirstName      = response.Contact.FirstName;
                    model.LastName       = response.Contact.LastName;
                    model.Email          = response.Contact.Email;
                    model.Street         = response.Contact.BillingAddress.StreetAndHouseNumber;
                    model.PostCode       = response.Contact.BillingAddress.PostCode;
                    model.PhoneNumber    = response.Contact.BillingAddress.PhoneNumber;
                    model.Prefecture     = response.Contact.BillingAddress.Prefecture;
                    model.City           = response.Contact.BillingAddress.CityOrTownOrVillage;
                    model.OrganisationId = response.Contact.ContactId;
                    model.CustomerGroup  = CustomerGroup.Customer;
                    PopulateErrorMessage(string.Empty);
                }
            }
            return(View(model));
        }
        public AgencyResponse Create(AgencyViewModel Agency)
        {
            AgencyResponse response = new AgencyResponse();

            try
            {
                response = WpfApiHandler.SendToApi <AgencyViewModel, AgencyResponse>(Agency, "Create");
            }
            catch (Exception ex)
            {
                response.Agency  = new AgencyViewModel();
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }
        public AgencyListResponse GetAgenciesForPopup(int companyId, Guid sectorIdentifier, string filterString)
        {
            AgencyListResponse     response = new AgencyListResponse();
            List <AgencyViewModel> Agencies = new List <AgencyViewModel>();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                try
                {
                    SqliteCommand selectCommand = new SqliteCommand(
                        SqlCommandSelectPart +
                        "FROM Agencies " +
                        "WHERE (@Filter IS NULL OR @Filter = '' OR Code LIKE @Filter OR Name LIKE @Filter) " +
                        "AND SectorIdentifier = @SectorIdentifier " +
                        "AND CompanyId = @CompanyId " +
                        "ORDER BY IsSynced, Id DESC " +
                        "LIMIT @ItemsPerPage;", db);

                    selectCommand.Parameters.AddWithValue("@Filter", ((object)filterString) != null ? "%" + filterString + "%" : "");
                    selectCommand.Parameters.AddWithValue("@SectorIdentifier", sectorIdentifier);
                    selectCommand.Parameters.AddWithValue("@CompanyId", ((object)companyId) != null ? companyId : 0);
                    selectCommand.Parameters.AddWithValue("@ItemsPerPage", 100);

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    while (query.Read())
                    {
                        AgencyViewModel dbEntry = Read(query);
                        Agencies.Add(dbEntry);
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage = error.Message;
                    response.Success        = false;
                    response.Message        = error.Message;
                    response.Agencies       = new List <AgencyViewModel>();
                    return(response);
                }
                db.Close();
            }
            response.Success  = true;
            response.Agencies = Agencies;
            return(response);
        }
Exemplo n.º 28
0
        public IActionResult Add(AgencyViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (!_agencyService.Exists(model.AgencyName))
            {
                _agencyService.AddOrUpdate(model);
            }
            else
            {
                return(BadRequest($"Agency {model.AgencyName} already exists."));
            }

            return(Ok());
        }
Exemplo n.º 29
0
        public async Task <IActionResult> SendNotification(AgencyViewModel model, string txt_note = "")
        {
            var agency = await _IAgencyBusiness.GetAgency(model.Id);

            if (agency == null)
            {
                TempData["MessageError"] = "Doanh nghiệp không tồn tại!";
            }
            else
            {
                await _INotificationBusiness.CreateNotification(EntityType.Agency, model.Id, model.Id,
                                                                NotificationType.SystemSendNotifycation, txt_note, "");


                TempData["MessageSuccess"] = "Đã gửi thông báo thành công!";
            }
            return(RedirectToAction("SendNotification", "Agency", new { id = model.Id }));
        }
        public AgencyResponse Delete(Guid identifier)
        {
            AgencyResponse response = new AgencyResponse();

            try
            {
                AgencyViewModel re = new AgencyViewModel();
                re.Identifier = identifier;
                response      = WpfApiHandler.SendToApi <AgencyViewModel, AgencyResponse>(re, "Delete");
            }
            catch (Exception ex)
            {
                response.Agency  = new AgencyViewModel();
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }