public ActionResult Update(int id, FeeDTO fee)
 {
     if (id <= 0 || !ModelState.IsValid || id != fee.Id)
     {
         return(BadRequest(new { message = "ID is invalid" }));
     }
     if (!_feeModel.UpdateDTO(id, fee))
     {
         return(Problem(statusCode: 500, detail: "Can't update data"));
     }
     _cache.DataUpdated(CacheKey.FEE);
     return(Ok());
 }
        public ActionResult <FeeDTO> Add(FeeDTO fee)
        {
            if (fee.Id != 0 || !ModelState.IsValid)
            {
                return(BadRequest(new { message = "Add method is invalid, field 'ID' not require" }));
            }
            var re = _feeModel.AddDTO(fee);

            if (re == null)
            {
                return(Problem(statusCode: 500, detail: "Can't add data"));
            }
            _cache.DataUpdated(CacheKey.FEE);
            return(re);
        }
Exemple #3
0
        public FeeDTO toDTO()
        {
            FeeDTO dto = new FeeDTO()
            {
                FeeID = this.FeeID,
                Value = this.Value,
                Paid  = this.Paid,

                RentalID = this.RentalID,
                CopyID   = this.Rental.CopyID,
                Title    = (this.Rental.Copy.Game.Title +
                            " (" + this.Rental.Copy.Game.Year.Year +
                            ", " + this.Rental.Copy.Game.Publisher.Name + ")"),

                Client = this.Rental.Client.FirstMidName + " " + this.Rental.Client.LastName
            };

            return(dto);
        }
        void SetupAndPost()
        {
            var feeDTO = new FeeDTO ();
            try {
                feeDTO.tariffCodeID = selectedTariff.id;
                feeDTO.matterID = Convert.ToInt16 (matter.id);
                if (isTimeBased) {
                    feeDTO.duration = (hours * 60) + minutes;
                    if (feeDTO.duration == 0) {
                        new UIAlertView (
                            "Duration Error",
                            "Please enter the duration for the fee before posting",
                            null,
                            "OK"
                        ).Show ();
                        return;
                    }
                }

                Console.WriteLine ("FeeAmount.Value: " + feeAmount.Value);
                string output = Stripper.StripByRegionFormat (feeAmount.Value);
                Console.WriteLine ("`setupAndPost - stripped amt: " + output);

                amount = double.Parse (output.Trim (),
                    CultureInfo.InvariantCulture);
                Console.WriteLine ("`setupAndPost - parsed amount: " + amount);
                feeDTO.amount = amount;
                feeDTO.date = Tools.ConvertDateTimeToJavaMS (DateTime.Now);
                if (amount == 0) {
                    new UIAlertView (
                        "Fee Amount Error",
                        "Please enter or calculate the amount for the fee before posting",
                        null,
                        "OK"
                    ).Show ();
                    return;
                }
                if (narration.Value.Trim ().Length == 0) {
                    new UIAlertView (
                        "Narration Error",
                        "Please enter a proper narration for the fee before posting",
                        null,
                        "OK"
                    ).Show ();
                    return;
                }
                feeDTO.narration = narration.Value;
                PostFeeToOffice (feeDTO);
            } catch (Exception e) {
                Console.WriteLine ("### ERROR: " + e.Message);
                new UIAlertView (
                    "Amount Error",
                    "Please enter a proper amount for the fee before posting",
                    null,
                    "OK"
                ).Show ();
                return;
            }
        }
        public void PostFeeToOffice(FeeDTO fee)
        {
            if (isBusy) {
                Console.WriteLine ("##PostFee: comms are busy, slow down!");
                return;
            }
            isBusy = true;
            BuildInterface ();
            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
            start = DateTime.Now;
            GhostRequestDTO cr = new GhostRequestDTO ();
            string json, encodedJSON, url;
            if (isTimeBased) {

            }
            if (isUnbillable) {
                cr.requestType = GhostRequestDTO.POST_UNBILLABLE_FEE;
            } else {
                cr.requestType = GhostRequestDTO.POST_FEE;
            }
            cr.fee = fee;
            cr.appID = NSUserDefaults.StandardUserDefaults.IntForKey ("appID");
            cr.userID = NSUserDefaults.StandardUserDefaults.IntForKey ("userID");
            cr.companyID = NSUserDefaults.StandardUserDefaults.IntForKey ("companyID");
            cr.deviceID = NSUserDefaults.StandardUserDefaults.StringForKey ("deviceID");

            json = JsonConvert.SerializeObject (cr);
            Console.WriteLine ("##PostFee JSON = " + json);
            encodedJSON = HttpUtility.UrlEncode (json);
            url = Tools.CONSOLE_URL + encodedJSON;

            var request = (HttpWebRequest)WebRequest.Create (url);
            request.BeginGetResponse (PostComplete, request);
        }