Example #1
0
        public string UpdateTarget()
        {
            DataAbstractionLayer dal = new DataAbstractionLayer();
            string name          = Request.Params["Name"];
            string desc          = Request.Params["Description"];
            bool   isValidId     = Int32.TryParse(Request.Params["TargetID"], out int targetID);
            bool   isValidPrice  = Decimal.TryParse(Request.Params["Price"], out decimal price);
            bool   isValidDestId = Int32.TryParse(Request.Params["DestinationID"], out int destinationId);

            if (isValidId && isValidPrice && isValidDestId && !string.IsNullOrEmpty(name))
            {
                dal.UpdateTarget(new Target
                {
                    TargetID      = targetID,
                    Name          = name,
                    Description   = desc,
                    Price         = price,
                    DestinationID = destinationId
                });
                return("Target updated successfully!");
            }
            return("Some field(s) have invalid values, please fix before proceeding.");
        }