Ejemplo n.º 1
0
        public static void validateAddPromo(ManagePromo managePromo)
        {
            if (managePromo.EstimateAmount == 0)
            {
                throw new DataValidationException($"EstimateAmount does not exists");
            }
            if (managePromo.Value == 0)
            {
                throw new DataValidationException($"Value does not exists");
            }
            if (managePromo.Zoneid == 0)
            {
                throw new DataValidationException($"Zoneid does not exists");
            }
            if (managePromo.Uses == 0)
            {
                throw new DataValidationException($"Uses does not exists");
            }
            if (managePromo.RepeatedlyUse == 0)
            {
                throw new DataValidationException($"RepeatedlyUse does not exists");
            }
            if (string.IsNullOrEmpty(managePromo.CoupenCode))
            {
                throw new DataValidationException($"CoupenCode does not exists");
            }

            /*if (string.IsNullOrEmpty(managePromo.Operation))
             * {
             *  throw new DataValidationException($"Operation does not exists");
             * }*/
        }
Ejemplo n.º 2
0
        public bool AddPromo(ManagePromo managePromo, TaxiAppzDBContext content, LoggedInUser loggedIn)
        {
            var emailid = content.TabZone.FirstOrDefault(t => t.IsDeleted == 0 && t.Zoneid == managePromo.Zoneid);

            if (emailid == null)
            {
                throw new DataValidationException($"Zone does not already exists.");
            }



            TabPromo tabPromo = new TabPromo();

            tabPromo.CouponCode          = managePromo.CoupenCode;
            tabPromo.PromoEstimateAmount = managePromo.EstimateAmount;
            tabPromo.PromoValue          = managePromo.Value;
            tabPromo.Zoneid                = managePromo.Zoneid;
            tabPromo.PromoType             = managePromo.CoupenCode;
            tabPromo.PromoUses             = managePromo.Uses;
            tabPromo.PromoUsersRepeateduse = managePromo.Value;
            tabPromo.StartDate             = managePromo.StartDate;
            tabPromo.EndDate               = managePromo.ExpiryDate;
            tabPromo.IsActive              = true;
            tabPromo.IsDelete              = true;
            tabPromo.UpdatedAt             = tabPromo.CreatedAt = DateTime.UtcNow;
            tabPromo.UpdatedBy             = tabPromo.CreatedBy = loggedIn.UserName;
            content.TabPromo.Add(tabPromo);
            content.SaveChanges();
            return(true);
        }
Ejemplo n.º 3
0
        public ManagePromo GetPromoDetails(long promoid, TaxiAppzDBContext content)
        {
            try
            {
                ManagePromo managepromo  = new ManagePromo();
                var         promodetails = content.TabPromo.Where(t => t.Promoid == promoid).FirstOrDefault();
                if (promodetails != null)
                {
                    managepromo.CoupenCode     = promodetails.CouponCode;
                    managepromo.EstimateAmount = promodetails.PromoEstimateAmount;
                    managepromo.Value          = promodetails.PromoValue;
                    managepromo.Zoneid         = promodetails.Zoneid;

                    managepromo.Uses          = promodetails.PromoUses;
                    managepromo.RepeatedlyUse = promodetails.PromoUsersRepeateduse;
                    managepromo.StartDate     = promodetails.StartDate;
                    managepromo.ExpiryDate    = promodetails.EndDate;
                    return(managepromo);
                }
                return(null);
            }
            catch (Exception ex)
            {
                Extention.insertlog(ex.Message, "Admin", "GetPromoDetails", content);
                return(null);
            }
        }
Ejemplo n.º 4
0
 public IActionResult EditPromo(ManagePromo managePromo)
 {
     try
     {
         Validator.validateEditPromo(managePromo);
         DAPromo dAPromo = new DAPromo();
         return(this.OK(dAPromo.EditPromo(managePromo, _content) ? "Recored Edited Successfully" : "Failed to Edit"));
     }
     catch (DataValidationException ex)
     {
         return(this.KnowOperationError(ex.Message));
     }
 }
Ejemplo n.º 5
0
 public IActionResult AddPromo(ManagePromo managePromo)
 {
     try
     {
         Validator.validateAddPromo(managePromo);
         DAPromo dAPromo = new DAPromo();
         return(this.OK(dAPromo.AddPromo(managePromo, _content, User.ToAppUser()) ? "Recored Added Successfully" : "Failed to Add"));
     }
     catch (DataValidationException ex)
     {
         return(this.KnowOperationError(ex.Message));
     }
 }
Ejemplo n.º 6
0
        public bool EditPromo(ManagePromo managePromo, TaxiAppzDBContext content)
        {
            var emailid = content.TabPromo.FirstOrDefault(t => t.IsDelete == false && t.Promoid == managePromo.PromoID);

            if (emailid == null)
            {
                throw new DataValidationException($"Promo does not exists.");
            }

            var zone = content.TabZone.FirstOrDefault(t => t.IsDeleted == 0 && t.Zoneid == managePromo.Zoneid);

            if (zone == null)
            {
                throw new DataValidationException($"Zone does not already exists.");
            }

            var promodetails = content.TabPromo.Where(t => t.Promoid == managePromo.PromoID && t.IsDelete == false).FirstOrDefault();

            if (promodetails != null)
            {
                promodetails.CouponCode          = managePromo.CoupenCode;
                promodetails.PromoEstimateAmount = managePromo.EstimateAmount;
                promodetails.PromoValue          = managePromo.Value;
                promodetails.Zoneid                = managePromo.Zoneid;
                promodetails.PromoType             = managePromo.CoupenCode;
                promodetails.PromoUses             = managePromo.Uses;
                promodetails.PromoUsersRepeateduse = managePromo.Value;
                promodetails.StartDate             = managePromo.StartDate;
                promodetails.EndDate               = managePromo.ExpiryDate;
                promodetails.IsActive              = true;
                promodetails.UpdatedAt             = DateTime.UtcNow;
                promodetails.UpdatedBy             = "Admin";
                content.SaveChanges();
                return(true);
            }

            return(false);
        }