コード例 #1
0
 public HomeController()
 {
     if (Cats.ready == false)
     {
         Cats.GatherCats();
     }
 }
コード例 #2
0
ファイル: DatabaseVet.cs プロジェクト: blackboxlogic/Cos470
        private static Cats execute(string queryString, bool andRead)
        {
            string connectionString = @"Server=localhost\SQLEXPRESS;User Id=open;Password=open;integrated security=false";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(queryString, connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                if (!andRead)
                {
                    return(null);
                }
                try
                {
                    Cats cats = new Cats();
                    cats.IdToName = new Dictionary <int, string>();
                    while (reader.Read())
                    {
                        Console.WriteLine(String.Format("{0}, {1}",
                                                        reader["id"], reader["catName"]));// etc
                        cats.IdToName.Add((int)reader["id"], (string)reader["catName"]);
                    }
                    return(cats);
                }
                finally
                {
                    reader.Close();
                }
            }
        }
コード例 #3
0
        async Task GetCats()
        {
            if (!IsBusy)
            {
                Exception Error = null;
                try
                {
                    IsBusy = true;
                    var repo  = new Repository();
                    var items = await repo.GetCats();

                    Cats.Clear();
                    foreach (var item in items)
                    {
                        Cats.Add(item);
                    }
                }
                catch (Exception ex)
                {
                    Error = ex;
                }
                finally
                {
                    IsBusy = false;
                }
                if (Error != null)
                {
                    await Xamarin.Forms.Application.Current.MainPage.DisplayAlert(
                        "Error!", Error.Message, "OK");
                }
            }
            return;
        }
コード例 #4
0
        public async Task Should_Contain_Specific_Cat()
        {
            var cat  = Cats.FirstOrDefault();
            var cats = await CatRepository.GetAllAsync();

            cats.FirstOrDefault(x => x.Name == cat.Name).Should().NotBeNull();
        }
コード例 #5
0
        async Task GetCats()
        {
            if (!IsBusy)
            {
                Exception Error = null;
                try
                {
                    IsBusy = true;
                    var Repository = new Repository();
                    var Items      = await Repository.GetCats();

                    Cats.Clear();
                    foreach (var Cat in Items)
                    {
                        Cats.Add(Cat);
                    }
                }
                catch (Exception ex)
                {
                    Error = ex;
                }
                finally
                {
                    IsBusy = false;
                }

                //mostrar uma mensagem em caso de que se tenha gerado uma exceção.
                if (Error != null)
                {
                    await Xamarin.Forms.Application.Current.MainPage.DisplayAlert(
                        "Error!", Error.Message, "OK");
                }
            }
            return;
        }
コード例 #6
0
ファイル: OrderController.cs プロジェクト: gnubatar/Cats
        public ActionResult OrderKart()
        {
            ViewBag.Errormsg = TempData["WrongKart"];
            var newOrder = Session["NewOrder"] as NewOrder;
            var cats     = Session["cats"] as Cats;
            var catsList = new List <Cats>();

            if (cats != null && newOrder != null)
            {
                Cats catList = new Cats();
                foreach (var cat in cats.cats)
                {
                    if (newOrder.catsIds.Contains(cat.id))
                    {
                        catList.cats.Add(cat);
                    }
                }
                catsList.Add(catList);
                Session["catsList"] = catsList;
                Session["cats"]     = catList;


                return(View(catList));
            }
            else
            {
                TempData["Error"] = "välj katter först";
                return(RedirectToAction("cats", "Home"));
            }
        }
コード例 #7
0
        public async Task GetCatBySecondaryId_ForSecondaryId_Successful()
        {
            var lastCat = Cats.LastOrDefault();
            var cat     = await CatController.GetBySecondaryId(lastCat.SecondaryId);

            cat.Id.Should().Be(lastCat.Id);
        }
コード例 #8
0
        public async Task <ActionResult <Cats> > PostCats(Cats cats)
        {
            _context.Cats.Add(cats);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCats", new { id = cats.Id }, cats));
        }
コード例 #9
0
        private void LoadMoreDataAsync()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            _deviceService.BeginInvokeOnMainThread(async() => {
                try
                {
                    foreach (var cat in await _catService.GetAllAsync())
                    {
                        Cats.Add(cat);
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }
                finally
                {
                    IsBusy = false;
                }
            });
        }
コード例 #10
0
        private async void ExecuteShareCommand()
        {
            if (Cats == null)
            {
                return;
            }

            var cat = Cats.ElementAt(CardIndex);

            if (cat == null)
            {
                return;
            }

            if (CrossShare.IsSupported)
            {
                if (await CrossShare.Current.Share(new ShareMessage
                {
                    Title = "Miauuu!",
                    Url = cat.Url
                }))
                {
                    Debug.WriteLine($"{cat.Url} shared");
                }
                ;
            }
        }
コード例 #11
0
        async Task GetCats()
        {
            if (!IsBusy)
            {
                Exception Error = null;
                try
                {
                    IsBusy = true;
                    var repository = new Repository();
                    var items      = await repository.GetCats();

                    Cats.Clear();
                    Cats.AddRange(items);
                }
                catch (Exception ex)
                {
                    Error = ex;
                }
                finally
                {
                    if (Error != null)
                    {
                        await messageService.ShowOkAsync("Error!", Error.Message);
                    }
                    IsBusy = false;
                }
            }
            return;
        }
コード例 #12
0
        public CatRepository()
        {
            var barry = new Cat()
            {
                Birth  = TimestampFactory.GetTimestamp(new DateTime(2017, 11, 5, 3, 45, 0)),
                Hungry = false,
                Mood   = Mood.Amber,
                Id     = Guid.NewGuid().ToString(),
                Name   = "Barry"
            };

            var doug = new Cat()
            {
                Birth  = TimestampFactory.GetTimestamp(new DateTime(2018, 5, 4, 13, 25, 13)),
                Hungry = true,
                Mood   = Mood.Red,
                Id     = Guid.NewGuid().ToString(),
                Name   = "Doug"
            };

            var fluffy = new Cat()
            {
                Birth  = TimestampFactory.GetTimestamp(new DateTime(2010, 2, 19, 4, 15, 25)),
                Hungry = false,
                Mood   = Mood.Green,
                Id     = Guid.NewGuid().ToString(),
                Name   = "Fluffy"
            };

            Cats.AddOrOverwrite(barry.Id, barry);
            Cats.AddOrOverwrite(doug.Id, doug);
            Cats.AddOrOverwrite(fluffy.Id, fluffy);
        }
コード例 #13
0
        async Task GetCats()
        {
            if (!IsBusy)
            {
                Exception error = null;

                try
                {
                    IsBusy = true;
                    var Repositaro = new Repository();
                    var Items      = await Repositaro.GetCats();

                    Cats.Clear();
                    foreach (var Cat in Items)
                    {
                        Cats.Add(Cat);
                    }
                }
                catch (Exception ex)
                {
                    error = ex;
                }
                finally
                {
                    if (error != null)
                    {
                        await Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Error", error.Message, "Ok");
                    }
                    IsBusy = false;
                }
            }

            return;
        }
コード例 #14
0
        public async Task <IActionResult> PutCats(int id, Cats cats)
        {
            if (id != cats.Id)
            {
                return(BadRequest());
            }

            _context.Entry(cats).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CatsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #15
0
        public async Task GetCats()
        {
            if (!IsBusy)
            {
                try
                {
                    IsBusy = true;
                    var items = await _repository.GetCats();

                    Cats.Clear();
                    foreach (var cat in items)
                    {
                        Cats.Add(cat);
                    }
                }
                catch (Exception ex)
                {
                    Error = ex;
                }
                finally
                {
                    IsBusy = false;

                    if (Error != null)
                    {
                        await Application.Current.MainPage.DisplayAlert("Error!", Error.Message, "Ok");
                    }
                }
            }
        }
コード例 #16
0
ファイル: Sub_Add.aspx.cs プロジェクト: XJHSG/SEST
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["RoleID"] == null || Session["UserID"] == null)
         {
             Util.ShowMessage("用户登录超时,请重新登录!", "Login2.aspx");
         }
         else
         {
             int RoleID = Convert.ToInt16(Session["RoleID"].ToString());
             if (RoleID > 1)
             {
                 Util.ShowMessage("对不起,你无权访问该页面!", "User_Center.aspx");
             }
             else
             {
                 using (SqlConnection conn = new DB().GetConnection())
                 {
                     SqlCommand cmd = conn.CreateCommand();
                     cmd.CommandText = "select * from Cats order by Orders desc";
                     conn.Open();
                     SqlDataReader rd = cmd.ExecuteReader();
                     Cats.DataSource     = rd;
                     Cats.DataValueField = "ID";
                     Cats.DataTextField  = "CatName";
                     Cats.DataBind();
                     rd.Close();
                 }
             }
         }
     }
 }
コード例 #17
0
        public async Task <string> Seed()
        {
            int numberOfCats = 0;

            if (_context.Cats.Count() == 0)
            {
                Cats cat1 = new Cats {
                    name = "Minister", breed = "Maine Coon"
                };
                Cats cat2 = new Cats {
                    name = "Miss Maypole", breed = "Siamese"
                };
                Cats cat3 = new Cats {
                    name = "Sparkles", breed = "Russian Blue"
                };
                Cats cat4 = new Cats {
                    name = "Dodger", breed = "Ragdoll"
                };
                Cats cat5 = new Cats {
                    name = "Barnaby", breed = "Sphynx"
                };

                _context.AddRange(cat1, cat2, cat3, cat4, cat5);
                await _context.SaveChangesAsync();

                numberOfCats = 5;
            }

            return($"{numberOfCats} Cats Added");
        }
コード例 #18
0
        public async Task Should_Get_Cat_By_Id()
        {
            var cat         = Cats.FirstOrDefault();
            var existingCat = await CatRepository.GetByIdAsync(cat.Id);

            existingCat.Name.Should().Be(cat.Name);
        }
コード例 #19
0
        public async Task GetAll_SpecificCatExists_Successful()
        {
            var cat  = Cats.FirstOrDefault();
            var cats = await CatRepository.GetAll();

            cats.FirstOrDefault(x => x.Name == cat.Name).Should().NotBeNull();
        }
コード例 #20
0
ファイル: CatsTesting.cs プロジェクト: Soyvolon/Shatter
        public async Task CatArgumentsTest()
        {
            var res = await Cats.GetCatDataAsync();

            Assert.NotNull(res);

            res = await Cats.GetCatDataAsync("desc");

            Assert.NotNull(res);
            Assert.NotZero(res.Length, "Missing Cat item");

            res = await Cats.GetCatDataAsync("random", "gif");

            Assert.NotNull(res);
            Assert.NotZero(res.Length, "Missing Cat item");
            Assert.True(Path.GetExtension(res[0].Url).Contains("gif"), "File type incorrect");

            res = await Cats.GetCatDataAsync("gif", "jpg", "random");

            Assert.NotNull(res);
            Assert.NotZero(res.Length, "Missing Cat item");
            Assert.True(Path.GetExtension(res[0].Url).Contains("jpg") ||
                        Path.GetExtension(res[0].Url).Contains("gif"), "File type incorrect.");

            res = await Cats.GetCatDataAsync("foo", "bar");

            Assert.NotNull(res);
            Assert.NotZero(res.Length, "Missing Cat item");
        }
コード例 #21
0
        public async Task LoadAsync()
        {
            Int64 startTicks = Log.VIEWMODEL("(NavigationViewModel) Enter", Common.LOG_CATEGORY);

            var lookupCats = await _CatLookupDataService.GetCatLookupAsync();

            Cats.Clear();

            foreach (var item in lookupCats)
            {
                Cats.Add(
                    new NavigationItemViewModel(item.Id, item.DisplayMember,
                                                nameof(CatDetailViewModel),
                                                EventAggregator, DialogService));
            }

            var lookupDogs = await _DogLookupDataService.GetDogLookupAsync();

            Dogs.Clear();

            foreach (var item in lookupDogs)
            {
                Dogs.Add(
                    new NavigationItemViewModel(item.Id, item.DisplayMember,
                                                nameof(DogDetailViewModel),
                                                EventAggregator, DialogService));
            }

            //TODO(crhodes)
            // Load more TYPEs as needed here

            Log.VIEWMODEL("(NavigationViewModel) Exit", Common.LOG_CATEGORY, startTicks);
        }
コード例 #22
0
        public void CreateAndUpdateCatsTest()
        {
            var options = new DbContextOptionsBuilder <CatMashDbContext>()
                          .UseInMemoryDatabase(databaseName: "Add_writes_to_database")
                          .Options;
            CatMashDbContext context = new CatMashDbContext(options);
            //// Act - Add the Cats
            var service = new CatMashService(context);
            var cat     = new Cats
            {
                CatMashId = 1,
                Note      = 5,
                Url       = "https://example.com",
                Id        = "bmp"
            };

            service.Add(cat);
            //// Assert
            Assert.AreEqual(1, context.Cats.Count());
            Assert.AreEqual("https://example.com", context.Cats.Single().Url);
            ///
            cat.Note = 10;
            service.Update(cat);
            var updatedCat = service.GetById(cat.CatMashId);

            // Asset
            Assert.AreEqual(cat.Note, updatedCat.Note);
        }
コード例 #23
0
        public async Task CatBySecondaryId_ForSecondaryId_Successful()
        {
            var cat         = Cats.FirstOrDefault();
            var existingCat = await CatRepository.GetBySecondaryId(cat.SecondaryId);

            existingCat.Name.Should().Be(cat.Name);
        }
コード例 #24
0
    public void CreatePref2(Cats _cat, bool _newest)
    {
        var dishes = AppManager.Instance.res.dish;

        System.Random rnd = new System.Random();
        cat_name.text = _cat.name;
        foreach (var dish in dishes)
        {
            if (_cat.tid == dish.cat && dish.newest == _newest)
            {
                dishToPref.Add(dish);
            }
        }

        if (dishToPref.Count > 6)
        {
            int count = dishToPref.Count - 6;
            for (int i = 1; i < count; i++)
            {
                int r = rnd.Next(0, dishToPref.Count - 1);
                dishToPref.RemoveAt(r);
            }
        }

        foreach (var dish in dishToPref)
        {
            var d = Instantiate(foodPref, ParentFoodPref.transform);
            d.GetComponent <FoodPrefScript>().ScrollCellContent(dish);
        }
    }
コード例 #25
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Photo,SpeciesId,Age,Info")] Cats cats)
        {
            if (id != cats.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cats);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CatsExists(cats.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cats));
        }
コード例 #26
0
ファイル: HubsController.cs プロジェクト: FishAbe/cats
        public ActionResult DeleteJson([DataSourceRequest] DataSourceRequest request, Cats.Models.Hubs.HubView viewModel)
        {
            var original = _hubService.FindById(viewModel.HubId);
            _hubService.DeleteHub(original);

            return Json(new[] { viewModel }.ToDataSourceResult(request, ModelState));
        }
コード例 #27
0
        public async Task <IActionResult> Create([Bind("Id,Name,Photo,SpeciesId,Age,Info")] Cats cats)
        {
            int counter = 0;

            foreach (var a in _context.Cats)
            {
                if (a.Name == cats.Name)
                {
                    counter++; break;
                }
            }
            if (counter != 0)
            {
                ModelState.AddModelError("Name", "Така тваринка вже існує");
                return(View(cats));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    _context.Add(cats);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                return(View(cats));
            }
        }
コード例 #28
0
        public DeliveryController(ITransportOrderService transportOrderService,
                                      IWorkflowStatusService workflowStatusService,
                                      IDispatchAllocationService dispatchAllocationService,
                                      IDeliveryService deliveryService,
            IDispatchService dispatchService,
            IDeliveryDetailService deliveryDetailService,
            INotificationService notificationService, IActionTypesService actionTypeService, IUserAccountService userAccountService,
            Cats.Services.EarlyWarning.ICommodityService commodityService, Cats.Services.EarlyWarning.IUnitService unitService,
            Cats.Services.Transaction.ITransactionService transactionService, IBusinessProcessService businessProcessService, IApplicationSettingService applicationSettingService, ITransporterPaymentRequestService transporterPaymentRequestService)
        {
            _transportOrderService = transportOrderService;
            _workflowStatusService = workflowStatusService;
            _dispatchAllocationService = dispatchAllocationService;
            _deliveryService = deliveryService;
            _dispatchService = dispatchService;
            _deliveryDetailService = deliveryDetailService;
            _notificationService = notificationService;

            _actionTypeService = actionTypeService;

            _userAccountService = userAccountService;
            _commodityService = commodityService;
            _unitService = unitService;
            _transactionService = transactionService;
            _businessProcessService = businessProcessService;
            _applicationSettingService = applicationSettingService;
            _transporterPaymentRequestService = transporterPaymentRequestService;
        }
コード例 #29
0
        public JsonResult getCat(int id)
        {
            Cats cat = findACatById(id);


            return(Json(cat));
        }
コード例 #30
0
        //Atualiza os dados locais do Gato de maneira assincrona
        async Task GetCats()
        {
            if (!IsBusy)
            {
                Exception Error = null;
                try {
                    IsBusy = true;
                    // cria instancia do repositório e inicia a tarefa assincrona
                    var Repository = new Repository();
                    var Items      = await Repository.GetCatsAzure();

                    //Limpa lista de e adiciona valores atualizados
                    Cats.Clear();
                    foreach (var Cat in Items)
                    {
                        Cats.Add(Cat);
                    }
                } catch (Exception ex) {
                    Error = ex;
                } finally {
                    IsBusy = false;
                }
                // se ocorreu um erro mostre para o usuário
                if (Error != null)
                {
                    await Xamarin.Forms.Application.Current.MainPage.DisplayAlert(
                        "Error!", Error.Message, "OK");
                }
            }
            return;
        }
コード例 #31
0
ファイル: Run.cs プロジェクト: tuanpth1909/Learn_CSharp_FPT
        public static void Test()
        {
            //bai 1
            Dog objdog = new Dog();

            objdog.Eat();
            objdog.Feature();
            objdog.Noise();

            //bai 2
            Cats objCat = new Cats();

            objCat.Food     = "Mouse";
            objCat.Activity = "lazearound";
            Console.WriteLine("The Cat loves to eats" + objCat.Food + ".");
            Console.WriteLine("The Catloves to" + objCat.Activity + ".");

            //bai 3
            Deparment objDeparment = new Deparment();

            objDeparment.Display();

            //bai 4
            Canine objCanine = new Canine();
        }
コード例 #32
0
ファイル: CatsExample.cs プロジェクト: remar/cats-cs-examples
        public void Update()
        {
            float delta = (SDL.SDL_GetTicks() - lastFrameTime) / 1000.0f;

            lastFrameTime = SDL.SDL_GetTicks();

            if (spriteId != -1)
            {
                pos += dx * delta;
                if (pos >= 640 - 16 && dx > 0)
                {
                    pos = 640 - 16;
                    dx  = -dx;
                    Cats.SetAnimation(spriteId, "walk left");
                }
                else if (pos <= 0 && dx < 0)
                {
                    pos = 0;
                    dx  = -dx;
                    Cats.SetAnimation(spriteId, "walk right");
                }
                Cats.SetSpritePosition(spriteId, (int)pos, 200);
            }
            Cats.SetScroll(-(int)pos, 0);
            Redraw(delta);
        }
コード例 #33
0
 public bool ApproveRequest(int id, Cats.Models.Security.UserInfo userInfo)
 {
     var req = _unitOfWork.RegionalRequestRepository.FindById(id);
     req.Status = (int)RegionalRequestStatus.Approved;
     req.ApprovedBy = userInfo.UserProfileID;
     _unitOfWork.Save();
     return true;
 }
コード例 #34
0
 public static HubViewModel BindHubViewModel(Cats.Models.Hub hub)
 {
     return new HubViewModel()
     {
         HubID = hub.HubID,
         HubName = hub.Name,
         HubOwnerID = hub.HubOwnerID
     };
 }
コード例 #35
0
 public UserPreferenceViewModel(Cats.Models.Security.UserProfile profile)
 {
     InitializeLookupValues();
     this.DateFormatPreference = profile.DatePreference;
     this.Language = profile.LanguageCode;
     this.WeightPrefernce = profile.PreferedWeightMeasurment;
     this.ThemePreference = profile.DefaultTheme;
     this.KeyboardLanguage = profile.Keyboard;
 }
コード例 #36
0
ファイル: UsersController.cs プロジェクト: FishAbe/cats
 // private readonly IUserAccountService _userAccountService;
 public UsersController(IUserAccountService service, IHubService hubService, IAdminUnitService adminUnitService, IProgramService programService, Cats.Services.Hub.IUserHubService userHubService)
 {
     _userService = service;
     _hubService = hubService;
     _adminUnitService = adminUnitService;
     _programService = programService;
     _userHubServcie = userHubService;
     //_userAccountService = userAccountService;
 }
コード例 #37
0
ファイル: ReportsController.cs プロジェクト: FishAbe/cats
 public static MasterReportBound GetOffloadingReport(Cats.Models.Hub.ViewModels.Report.Data.OffloadingReport offloadingreport)
 {
     var rpt = new OffLoadingReport();
     rpt.DataSource = offloadingreport;
     MasterReportBound report = new MasterReportBound();
     report.DataSource = offloadingreport;
     report.rptSubReport.ReportSource = rpt;
     return report;
 }
コード例 #38
0
ファイル: LedgerController.cs プロジェクト: robela/cats
 public ActionResult Edit(Cats.Models.Hubs.Ledger ledger)
 {
     if(ModelState.IsValid){
         _ledgerService.EditLedger(ledger);
         return Json(new { success = true });
     }
     ViewBag.hubOwnerID = new SelectList(_ledgerService.GetAllLedger().OrderBy(l => l.Name));
     return View();
 }
コード例 #39
0
ファイル: ReportsController.cs プロジェクト: FishAbe/cats
 public static MasterReportBound GetFreeStockReport(Cats.Models.Hub.ViewModels.Report.Data.FreeStockReport freestockreport)
 {
     var rpt = new Cats.Web.Hub.Reports.FreeStockReport();
     rpt.DataSource = freestockreport.Programs;
     var report = new MasterReportBound();
     //report.DataSource = freestockreport.Programs ;
     report.rptSubReport.ReportSource = rpt;
     return report;
 }
コード例 #40
0
ファイル: HubController.cs プロジェクト: edgecomputing/cats
        public virtual ActionResult Create(Cats.Models.Hubs.Hub warehouse)
        {
            if (ModelState.IsValid)
            {
                _hubService.AddHub(warehouse);
                return Json(new { success = true });
            }

            ViewBag.HubOwnerID = new SelectList(_hubOwnerService.GetAllHubOwner().OrderBy(o => o.Name), "HubOwnerID", "Name", warehouse.HubOwnerID);
            return PartialView(warehouse);
        }
コード例 #41
0
ファイル: LedgerController.cs プロジェクト: robela/cats
        public virtual ActionResult Create(Cats.Models.Hubs.Ledger ledger)
        {
            if (ModelState.IsValid)
            {
                _ledgerService.AddLedger(ledger);
                return Json(new { success = true });
            }

            //ViewBag.HubOwnerID = new SelectList(_ledgerService.GetAllLedger().OrderBy(l=>l.Name), "Name", "LedgerType", ledger.LedgerID);
            return PartialView(ledger);
        }
コード例 #42
0
ファイル: HubsController.cs プロジェクト: FishAbe/cats
 public ActionResult CreateJson([DataSourceRequest] DataSourceRequest request, Cats.Models.Hubs.HubView viewModel)
 {
     if (viewModel != null && ModelState.IsValid)
     {
         Cats.Models.Hubs.Hub original = new Cats.Models.Hubs.Hub{
             Name = viewModel.Name,
             HubOwnerID = viewModel.HubOwnerID
             };
         _hubService.AddHub(original);
     }
     return Json(new[] { viewModel }.ToDataSourceResult(request, ModelState));
 }
コード例 #43
0
        public ActionResult Create(Cats.Models.Transaction transaction)
        {
            if (ModelState.IsValid)
            {
                transaction.TransactionID = Guid.NewGuid();
                transaction.TransactionGroupID = Guid.NewGuid();

                _accountTransactionService.AddTransaction(transaction);

                return RedirectToAction("Index");

            }

            return View(transaction);
        }
コード例 #44
0
 public ContractAdministrationController(IPaymentRequestService paymentRequestService, ITransporterService transporterService,
     ITransportOrderService transportOrderService, IUserAccountService userAccountService, IDispatchAllocationService dispatchAllocationService, 
     IWorkflowStatusService workflowStatusService, IDeliveryService distributionService, IBidWinnerService bidWinnerService,
     Cats.Services.EarlyWarning.IAdminUnitService adminUnitService)
 {
     _adminUnitService = adminUnitService;
     _paymentRequestService = paymentRequestService;
     _transporterService = transporterService;
     _transportOrderService = transportOrderService;
     _userAccountService = userAccountService;
     _dispatchAllocationService = dispatchAllocationService;
     _workflowStatusService = workflowStatusService;
     _distributionService = distributionService;
     _bidWinnerService = bidWinnerService;
 }
コード例 #45
0
ファイル: Cat.aspx.cs プロジェクト: johncoffee/eventblock
 public void LoadCat()
 {
     int catid;
     if (FriendlyUrl.Segments.Count > 0 && int.TryParse(FriendlyUrl.Segments[0], out catid))
     {
         cat = CatsLogic.GetItem(catid);
         if (cat != null)
         {
             SiteLogic.SetMeta(cat, Page);
             SideCats.CatId = cat.CatsId;
             Breadcrumbs.CurrentCat = cat;
         } else {
             Response.Redirect("~/index");
         }
     }
 }
コード例 #46
0
 public DeliveryReconcileController(IDispatchAllocationService dispatchAllocationService,
                               IDeliveryService deliveryService,
     IDispatchService dispatchService,
     Cats.Services.EarlyWarning.ICommodityService commodityService, Cats.Services.EarlyWarning.IUnitService unitService, 
     Cats.Services.Transaction.ITransactionService transactionService,
     Cats.Services.EarlyWarning.IAdminUnitService adminUnitService, Cats.Services.EarlyWarning.IFDPService fdpService,
     Cats.Services.Logistics.IDeliveryReconcileService deliveryReconcileService, IUserAccountService userAccountService)
 {
     _dispatchAllocationService = dispatchAllocationService;
     _deliveryService = deliveryService;
     _dispatchService = dispatchService;
     _commodityService = commodityService;
     _unitService = unitService;
     _transactionService = transactionService;
     _adminUnitService = adminUnitService;
     _fdpService = fdpService;
     _deliveryReconcileService = deliveryReconcileService;
     _userAccountService = userAccountService;
 }
コード例 #47
0
        public ActionResult HubAllocationDetail(Cats.Models.HubAllocation hubAllocation)
        {
            var seleList = new SelectList(_hubService.GetAllHub(), "HubId", "Name");
            ViewBag.HubId = seleList;
            IEnumerable<Cats.Models.HubAllocation> detail =
               _projectCodeAllocationService.Get(
                   t => t.HubID == hubAllocation.HubID);

            return View(detail);
        }
コード例 #48
0
ファイル: ReportsController.cs プロジェクト: FishAbe/cats
 public static MasterReportBound GetContainerReport(Cats.Models.Hub.ViewModels.Report.Data.BaseReport baseReportType)
 {
     MasterReportBound report = new MasterReportBound();
     report.DataSource = baseReportType;
     return report;
 }
コード例 #49
0
        public ActionResult Create(Cats.Models.Hubs.GiftCertificateViewModel giftcertificate)
        {
            if (ModelState.IsValid)
            {
                Cats.Models.Hubs.GiftCertificate giftCertificateModel = giftcertificate.GenerateGiftCertificate();

                InsertGiftCertificate(giftcertificate, giftCertificateModel);
                //repository.Add( giftCertificate );
                return RedirectToAction("Index");
            }

            ViewBag.Commodities = _commodityService.GetAllCommodity().OrderBy(o => o.Name);
            ViewBag.CommodityTypes = _commodityTypeService.GetAllCommodityType().OrderBy(o => o.Name);

            ViewBag.DCurrencies = _detailService.GetAllDetail().Where(d => d.MasterID == Master.Constants.CURRENCY).OrderBy(o => o.SortOrder);
            ViewBag.DFundSources = _detailService.GetAllDetail().Where(d => d.MasterID == Master.Constants.FUND_SOURCE).OrderBy(o => o.SortOrder);
            ViewBag.DBudgetTypes = _detailService.GetAllDetail().Where(d => d.MasterID == Master.Constants.BUDGET_TYPE).OrderBy(o => o.SortOrder);
            ViewBag.Donors = new SelectList(_donorService.GetAllDonor().OrderBy(o => o.Name), "DonorID", "Name");
            ViewBag.Programs = new SelectList(_programService.GetAllProgram(), "ProgramID", "Name");
            ViewBag.DModeOfTransports = new SelectList(_detailService.GetAllDetail().Where(d => d.MasterID == Master.Constants.TRANSPORT_MODE).OrderBy(o => o.SortOrder), "DetailID", "Name");

            //return the model with the values pre-populated
            return Create(); //GiftCertificateViewModel.GiftCertificateModel(giftcertificate));
        }
コード例 #50
0
 private void InsertGiftCertificate(Cats.Models.Hubs.GiftCertificateViewModel giftcertificate, Cats.Models.Hubs.GiftCertificate giftCertificateModel)
 {
     List<Cats.Models.Hubs.GiftCertificateDetailsViewModel> giftCertificateDetails = GetSelectedGiftCertificateDetails(giftcertificate.JSONInsertedGiftCertificateDetails);
     var giftDetails = GenerateGiftCertificate(giftCertificateDetails);
     foreach (GiftCertificateDetail giftDetail in giftDetails)
     {
         giftCertificateModel.GiftCertificateDetails.Add(giftDetail);
     }
     _giftCertificateService.AddGiftCertificate(giftCertificateModel);
 }
コード例 #51
0
 public TransactionService(Cats.Data.UnitWork.IUnitOfWork unitOfWork)
 {
     this._unitOfWork = unitOfWork;
 }
コード例 #52
0
        public ActionResult Edit(Cats.Models.Transaction transaction)
        {
            if (ModelState.IsValid)
            {

                _accountTransactionService.UpdateTransaction(transaction);
                return RedirectToAction("Index");
            }
            return View(transaction);
        }
コード例 #53
0
ファイル: UserWarehouse.cs プロジェクト: edgecomputing/cats
 public UserWarehouseController(IUserHubService userHubService, Cats.Services.EarlyWarning.IHubService hubService, IUserProfileService userProfileService)
 {
     this._userHubService = userHubService;
     this._hubService = hubService;
     this._userProfileService = userProfileService;
 }
コード例 #54
0
ファイル: HubOwnerController.cs プロジェクト: FishAbe/cats
 public Cats.Areas.Settings.Models.HubOwnerViewModel toViewModel(Cats.Models.Hubs.HubOwner item)
 {
     return new HubOwnerViewModel
         {
             Name = item.Name,
             HubOwnerID = item.HubOwnerID,
             LongName = item.LongName
         };
 }
コード例 #55
0
ファイル: HubsController.cs プロジェクト: FishAbe/cats
 public ActionResult UpdateJson([DataSourceRequest] DataSourceRequest request, Cats.Models.Hubs.HubView viewModel)
 {
     if (viewModel != null && ModelState.IsValid)
     {
         var original = _hubService.FindById(viewModel.HubId);
         original.Name = viewModel.Name;
         original.HubOwnerID = viewModel.HubOwnerID;
         _hubService.EditHub(original);
     }
      return Json(new[] { viewModel }.ToDataSourceResult(request, ModelState));
 }
コード例 #56
0
        private void PopulateLookup(bool isNew = true, Cats.Models.GiftCertificate giftCertificate = null)
        {
            ViewData["Commodities"] = _commonService.GetCommodities(null, t => t.OrderBy(o => o.Name));

            ViewBag.DCurrencies = _commonService.GetDetails(d => d.MasterID == Master.Constants.CURRENCY, t => t.OrderBy(o => o.SortOrder));
            ViewBag.DFundSources = _commonService.GetDetails(d => d.MasterID == Master.Constants.FUND_SOURCE, t => t.OrderBy(o => o.SortOrder));
            ViewBag.DBudgetTypes = _commonService.GetDetails(d => d.MasterID == Master.Constants.BUDGET_TYPE, t => t.OrderBy(o => o.SortOrder));

             var giftCertificateDetails = new List<GiftCertificateDetailsViewModel>();
             ViewBag.GiftCertificateDetails = giftCertificateDetails;
            if (isNew && giftCertificate == null)
            {
                ViewBag.DonorID = new SelectList(_commonService.GetDonors(null, t => t.OrderBy(o => o.Name)), "DonorID",
                                                 "Name");
                ViewBag.CommodityTypeID =
                    new SelectList(_commonService.GetCommodityTypes(null, t => t.OrderBy(o => o.Name)),
                                   "CommodityTypeID", "Name",1);
                ViewBag.ProgramID = new SelectList(_commonService.GetPrograms(), "ProgramID", "Name");
                ViewBag.DModeOfTransport = new SelectList(_commonService.GetDetails(d => d.MasterID == Master.Constants.TRANSPORT_MODE, t => t.OrderBy(o => o.SortOrder)), "DetailID", "Name");

            }
            else
            {
                var giftDetails = giftCertificate.GiftCertificateDetails.FirstOrDefault();
                ViewBag.DonorID = new SelectList(_commonService.GetDonors(null, t => t.OrderBy(o => o.Name)), "DonorID",
                                                "Name",giftCertificate.DonorID);
                ViewBag.CommodityTypeID =
                    new SelectList(_commonService.GetCommodityTypes(null, t => t.OrderBy(o => o.Name)),
                                   "CommodityTypeID", "Name", giftDetails == null ? "1" : giftDetails.Commodity.CommodityTypeID.ToString());
                ViewBag.ProgramID = new SelectList(_commonService.GetPrograms(), "ProgramID", "Name",giftCertificate.ProgramID);
                ViewBag.DModeOfTransport = new SelectList(_commonService.GetDetails(d => d.MasterID == Master.Constants.TRANSPORT_MODE, t => t.OrderBy(o => o.SortOrder)), "DetailID", "Name",giftCertificate.DModeOfTransport);

            }
        }
コード例 #57
0
ファイル: DonationController.cs プロジェクト: FishAbe/cats
        public ActionResult AddNewDonationPlan(Cats.Models.Hubs.ReceiptAllocationViewModel receiptAllocationViewModel)
        {
            ModelState.Remove("SourceHubID");
            ModelState.Remove("SupplierName");
            ModelState.Remove("PurchaseOrder");

            if (ModelState.IsValid)
            {
                var receiptAllocation = receiptAllocationViewModel.GenerateReceiptAllocation();

                if (receiptAllocationViewModel.GiftCertificateDetailID == 0 || receiptAllocationViewModel.GiftCertificateDetailID == null)
                {
                    var shippingInstruction = _shippingInstructionService.FindBy(t => t.Value == receiptAllocationViewModel.SINumber).FirstOrDefault();
                    var gc = new Cats.Models.GiftCertificate();
                    if (shippingInstruction != null)
                        gc = _giftCertificateService.FindBySINumber(shippingInstruction.Value);

                    if (gc != null)
                    {
                        var gcd = gc.GiftCertificateDetails.FirstOrDefault(p => p.CommodityID == receiptAllocationViewModel.CommodityID);
                        if (gcd != null)
                        {
                            receiptAllocation.GiftCertificateDetailID = gcd.GiftCertificateDetailID;
                        }
                    }
                    else
                    {
                        receiptAllocation.GiftCertificateDetailID = null;
                    }
                }

                receiptAllocation.HubID = receiptAllocationViewModel.HubID;
                receiptAllocation.CommoditySourceID = Cats.Models.Hubs.CommoditySource.Constants.DONATION;

                receiptAllocation.ReceiptAllocationID = Guid.NewGuid();
                _receiptAllocationService.AddReceiptAllocation(receiptAllocation);

                return RedirectToAction("Index");

            }

            return RedirectToAction("Index");
        }
コード例 #58
0
        private DeliveryViewModel CreateGoodsReceivingNote(Cats.Models.Hubs.Dispatch dispatch)
        {
            if (dispatch == null) return new DeliveryViewModel();
            var delivery = new DeliveryViewModel();
            delivery.DeliveryDate = DateTime.Today;
            delivery.DispatchID = dispatch.DispatchID;
            delivery.DeliveryDate = DateTime.Today;
            delivery.DocumentReceivedBy = UserAccountHelper.GetUser(User.Identity.Name).UserProfileID;
            delivery.DocumentReceivedDate = DateTime.Today;
            delivery.DeliveryID = Guid.NewGuid();
            //delivery.DonorID=dispatch.
            delivery.DriverName = dispatch.DriverName;
            delivery.FDPID = dispatch.FDPID.Value;
            delivery.HubID = dispatch.HubID;
            delivery.TransporterID = dispatch.TransporterID;
            delivery.InvoiceNo = dispatch.GIN;
            delivery.PlateNoPrimary = dispatch.PlateNo_Prime;
            delivery.PlateNoTrailler = dispatch.PlateNo_Trailer;
            delivery.RequisitionNo = dispatch.RequisitionNo;
            delivery.FDP = dispatch.FDP.Name;
            delivery.Region = dispatch.FDP.AdminUnit.AdminUnit2.AdminUnit2.Name;
            delivery.Zone = dispatch.FDP.AdminUnit.AdminUnit2.Name;
            delivery.Woreda = dispatch.FDP.AdminUnit.Name;
            delivery.Hub = dispatch.Hub.Name;
            delivery.Transporter = dispatch.Transporter.Name;

            //foreach (var dispatchDetail in dispatch.DispatchDetails)
            //{
            //    var deliveryDetail = new DistributionDetail();
            //    deliveryDetail.DistributionID = distribution.DistributionID;
            //    deliveryDetail.DistributionDetailID = Guid.NewGuid();
            //    deliveryDetail.CommodityID = dispatchDetail.CommodityID;
            //    deliveryDetail.ReceivedQuantity = 0;
            //    deliveryDetail.SentQuantity = dispatchDetail.RequestedQuantityInMT;
            //    deliveryDetail.UnitID = dispatchDetail.UnitID;

            //}
            return delivery;
        }