Exemplo n.º 1
0
        public IActionResult Upsert(int?id)
        {
            CoverType coverType = new CoverType();

            if (id == null)
            {
                //create
                return(View(coverType));
            }
            else
            {
                //edit
                var parameter = new DynamicParameters();
                parameter.Add("@Id", id);
                coverType = _unitOfWork.SP_Call.OneRecord <CoverType>(SD.Proc_CoverType_Get, parameter);

                if (coverType == null)
                {
                    return(NotFound());
                }
                return(View(coverType));
            }
        }
Exemplo n.º 2
0
        public IActionResult Upsert(int?id)
        {
            CoverType coverType = new CoverType();

            if (id == null)
            {
                //This for create
                return(View(coverType));
            }

            var parameter = new DynamicParameters();

            parameter.Add("@Id", id);
            coverType = _unitOfWork.sp_call.OneRecord <CoverType>(ProjectConstant.Proc_CoverType_Get, parameter);

            //cat = _unitOfWork.CoverType.Get((int)id);
            if (coverType != null)
            {
                return(View(coverType));
            }

            return(NotFound());
        }
Exemplo n.º 3
0
 [ValidateAntiForgeryToken] //writes the unique value to an HTTP only cookie and the same value if written to the form
                            //when the page is submitted, an error is reaised if cookie value is not matched with the form value
                            //prevent cross site forgery.
 public IActionResult Upsert(CoverType coverType)
 {
     if (ModelState.IsValid)                      //check data annotation and validation in model to see if everything is valid or not
     {
         var parameter = new DynamicParameters(); //whenever we work with Stored Procedures we need a dynamic parameters
         parameter.Add("@Name", coverType.Name);  //@Name from the stored procedures command
         if (coverType.Id == 0)
         {
             //create new cover Type
             _unitOfWork.SP_Call.Execute(SD.Proc_CoverType_Create, parameter);
             //since we have SaveChanges in Update but not in Add
         }
         else
         {
             //update new cover Type
             parameter.Add("@Id", coverType.Name);
             _unitOfWork.SP_Call.Execute(SD.Proc_CoverType_Update, parameter);
         }
         _unitOfWork.Save();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(coverType));
 }
Exemplo n.º 4
0
        public IActionResult Upsert(int?id)
        {
            CoverType coverType = new CoverType();

            if (id == null)
            {
                // Create
                return(View(coverType));
            }
            // Edit

            var parameter = new DynamicParameters();

            parameter.Add("id", id);
            //Console.WriteLine("EDIT ID: {0}", id);
            coverType = _unitOfWork.SP_Call.OneRecord <CoverType>(SD.Proc_CoverType_Get, parameter);

            if (coverType == null)
            {
                return(NotFound());
            }
            return(View(coverType));
        }
Exemplo n.º 5
0
        public IActionResult Upsert(CoverType coverType)
        {
            if (ModelState.IsValid)
            {
                var parameter = new DynamicParameters();
                parameter.Add("name", coverType.Name);
                //Console.WriteLine("NAME: {0}", coverType.Name);

                if (coverType.Id == 0)
                {
                    _unitOfWork.SP_Call.Execute(SD.Proc_CoverType_Create, parameter);
                }
                else
                {
                    parameter.Add("id", coverType.Id);
                    //Console.WriteLine("Update ID: {0}", coverType.Id);
                    _unitOfWork.SP_Call.Execute(SD.Proc_CoverType_Update, parameter);
                }
                _unitOfWork.Save();
                return(RedirectToAction(nameof(Index)));
            }
            return(View(coverType));
        }
Exemplo n.º 6
0
        public IActionResult Upsert(int?id)
        {
            CoverType coverType = new CoverType();

            if (id == null)
            {
                // this if for create
                return(View(coverType));
            }
            // this is for edit
            // coverType = _unitOfWork.CoverType.Get(id.GetValueOrDefault());

            var parameter = new DynamicParameters();

            parameter.Add("@Id", id);
            coverType = _unitOfWork.SP_Call.OneRecord <CoverType>(SD.Proc_CoverType_Get, parameter); // passing the id as parameter

            if (coverType == null)
            {
                return(NotFound());
            }
            return(View(coverType));
        }
        public IActionResult Upsert(int?id)
        {
            var coverType = new CoverType();

            //this is for create
            if (id == null)
            {
                return(View(coverType));
            }

            //this is for edit
            var parameter = new DynamicParameters();

            parameter.Add("@Id", id);
            coverType = _unitOfWork.SpCall.OneRecord <CoverType>(Sd.ProcCoverTypeGet, parameter);

            if (coverType == null)
            {
                return(NotFound());
            }

            return(View(coverType));
        }
Exemplo n.º 8
0
        public IActionResult Upsert(CoverType сoverType)
        {
            if (ModelState.IsValid)
            {
                var parameter = new DynamicParameters();
                parameter.Add("@Name", сoverType.Name);

                if (сoverType.Id == 0)
                {
                    _uniofWork.SP_Call.Execute(SD.Proc_CoverType_Create, parameter);
                }
                else
                {
                    parameter.Add("@Id", сoverType.Id);
                    _uniofWork.SP_Call.Execute(SD.Proc_CoverType_Update, parameter);
                }
                _uniofWork.Save();

                // return RedirectToAction("Index");
                return(RedirectToAction(nameof(Index)));
            }
            return(View(сoverType));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Constructs an AlbumArt with an already known full-size image
        /// </summary>
        public AlbumArt(Source source, string name, string infoUri, int width, int height, byte[] fullSizeImageData, CoverType coverType)
        {
            mSource    = source;
            ResultName = name;
            InfoUri    = infoUri;
            CoverType  = coverType;

            BitmapData = fullSizeImageData;
            FileSize   = fullSizeImageData.LongLength;

            if (width == -1 && height == -1 && Image != null)
            {
                //Have to decode the image data to get width and height
                SetImageDimensions(Image.PixelWidth, Image.PixelHeight);
            }
            else
            {
                //Believe the dimensions specified
                SetImageDimensions(width, height);
            }

            mIsFullSize = true;
        }
Exemplo n.º 10
0
        public IActionResult InsertOrUpdate(CoverType coverType)
        {
            if (ModelState.IsValid)
            {
                var parameter = new DynamicParameters();
                parameter.Add("@Name", coverType.Name);

                if (coverType.Id == 0)
                {
                    _unitOfWork.StoredProc_Call.Execute(SD.Proc_CoverType_Create, parameter);
                }
                else
                {
                    parameter.Add("@Id", coverType.Id);
                    _unitOfWork.StoredProc_Call.Execute(SD.Proc_CoverType_Update, parameter);
                }

                _unitOfWork.Save();
                return(RedirectToAction(nameof(Index)));
            }

            return(View(coverType));
        }
Exemplo n.º 11
0
        public IActionResult Upsert(int?id)
        {
            CoverType coverType = new CoverType();

            if (id == null)
            {
                //Create new CoverType
                return(View(coverType));
            }
            // Edit CoverType
            //coverType = _unitOfWork.CoverType.Get(id.GetValueOrDefault());
            var dynamicParameter = new DynamicParameters();

            dynamicParameter.Add("@Id", id);
            coverType = _unitOfWork.SP_Call.OneRecord <CoverType>(SD.Proc_CoverType_Get, dynamicParameter);

            if (coverType == null)
            {
                return(NotFound());
            }

            return(View(coverType));
        }
Exemplo n.º 12
0
        public IActionResult Upsert(CoverType coverType)
        {
            if (!ModelState.IsValid)
            {
                return(View(coverType));
            }
            var parameter = new DynamicParameters();

            parameter.Add("@Name", coverType.Name);

            if (coverType.Id != 0)
            {
                parameter.Add("@Id", coverType.Id);
                _unitOfWork.SP_Call.Execute(SD.Proc_CoverType_Update, parameter); // _unitOfWork.CoverType.Update(coverType);
            }
            else
            {
                _unitOfWork.SP_Call.Execute(SD.Proc_CoverType_Create, parameter); // _unitOfWork.CoverType.Add(coverType);
            }

            _unitOfWork.Save();
            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 13
0
        public IActionResult Upsert(CoverType coverType)
        {
            if (ModelState.IsValid)
            {
                var parameter = new DynamicParameters();

                if (coverType.Id == 0)
                {
                    //_unitOfWork.coverType.Add(coverType);
                    parameter.Add("@Name", coverType.Name);
                    _unitOfWork.spCall.Execute(ProjectConstant.Proc_CoverType_Create, parameter);
                }
                else
                {
                    //_unitOfWork.coverType.Update(coverType);
                    parameter.Add("@Id", coverType.Id);
                    _unitOfWork.spCall.Execute(ProjectConstant.Proc_CoverType_Update, parameter);
                }
                _unitOfWork.Save();
                return(RedirectToAction("Index"));
            }
            return(View(coverType));
        }
Exemplo n.º 14
0
        public IActionResult Upsert(int?id)
        {
            CoverType coverType = new CoverType();

            if (id == null)
            {
                //This to create
                return(View(coverType));
            }

            //Entity
            //coverType = _unitOfWork.coverType.Get(id.Value);

            //Dapper
            var parameter = new DynamicParameters();

            coverType = _unitOfWork.spCall.OneRecord <CoverType>(ProjectConstant.Proc_CoverType_Get, parameter);
            if (coverType == null)
            {
                return(NotFound());
            }
            return(View(coverType));
        }
Exemplo n.º 15
0
        public IActionResult Upsert(int?id)
        {
            CoverType coverType = new CoverType();

            // create
            if (id == null)
            {
                return(View(coverType));
            }

            // stored procedure
            // var parameter = new DynamicParameters();
            // parameter.Add("@Id", id);
            // coverType = _unitOfWork.SP_Call.OneRecord<CoverType>(SD.Proc_CoverType_Get, parameter);

            // edit
            coverType = _unitOfWork.CoverType.Get(id.GetValueOrDefault());
            if (coverType == null)
            {
                return(NotFound());
            }

            return(View(coverType));
        }
Exemplo n.º 16
0
        internal static AllowedCoverType MakeAllowedCoverType(CoverType scriptCoverType)
        {
            switch (scriptCoverType)
            {
            case CoverType.Unknown:
                return(AllowedCoverType.Unknown);

            case CoverType.Front:
                return(AllowedCoverType.Front);

            case CoverType.Back:
                return(AllowedCoverType.Back);

            case CoverType.Inside:
                return(AllowedCoverType.Inside);

            case CoverType.CD:
                return(AllowedCoverType.CD);

            case CoverType.Booklet:
                return(AllowedCoverType.Booklet);
            }
            return(AllowedCoverType.Unknown);
        }
 public IActionResult UpSert(CoverType covertype)
 {
     if (ModelState.IsValid)
     {
         if (covertype.Id == 0)
         {
             covertype.Inserted   = DateTime.Now;
             covertype.InsertedBy = 1;
             covertype.Updated    = DateTime.Now;
             covertype.UpdatedBy  = 1;
             _unitOfWork.CoverType.Add(covertype);
         }
         else
         {
             _unitOfWork.CoverType.Update(covertype);
         }
         _unitOfWork.Save();
         return(RedirectToAction(nameof(Index)));
     }
     else
     {
         return(NotFound());
     }
 }
Exemplo n.º 18
0
 public IActionResult Upsert(CoverType CoverType)
 {
     if (ModelState.IsValid)
     {
         var parameter = new DynamicParameters();
         parameter.Add("@Name", CoverType.Name);
         if (CoverType.Id == 0)
         {
             //create
             //_uow.CoverType.Add(CoverType);
             _uow.sp_call.Execute(ProjectConstant.Proc_CoverType_Create, parameter);
         }
         else
         {
             //update
             parameter.Add("@Id", CoverType.Id);
             // _uow.CoverType.Update(CoverType);
             _uow.sp_call.Execute(ProjectConstant.Proc_CoverType_Update, parameter);
         }
         _uow.Save();
         return(RedirectToAction("Index"));
     }
     return(View(CoverType));
 }
Exemplo n.º 19
0
        public IActionResult Upsert(CoverType coverType)
        {
            // Save if the model is valid
            if (ModelState.IsValid)
            {
                var parameter = new DynamicParameters();
                parameter.Add("@Name", coverType.Name);
                if (coverType.Id == 0)
                {
                    _unitOfWork.SP_Call.Execute(StaticDetails.Proc_CoverType_Create, parameter);
                }
                else
                {
                    parameter.Add("@Id", coverType.Id);
                    _unitOfWork.SP_Call.Execute(StaticDetails.Proc_CoverType_Update, parameter);
                }

                _unitOfWork.Save();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(coverType));
        }
Exemplo n.º 20
0
        public async Task <double> BasicPremium()
        {
            double percentage = 0;

            _value = _motor.Value;
            var result    = results.BasicPremium;
            var covertype = new CoverType();

            switch (covertype)
            {
            case CoverType.PrivateIndividual:
                percentage = 0.05;
                break;

            case CoverType.Corporate:
                percentage = 0.06;
                break;

            case CoverType.Taxi:
                percentage = 0.07;
                break;

            case CoverType.Hiring:
                percentage = 0.07;
                break;

            case CoverType.MiniBus:
                percentage = 0.07;
                break;

            case CoverType.MaxiBus:
                percentage = 0.07;
                break;

            case CoverType.MotorCycle:
                percentage = 0.03;

                break;

            case CoverType.Ambulance:
                percentage = 0.07;
                break;

            case CoverType.OwnGoods:
                percentage = 0.04;
                break;

            case CoverType.ArticulatorOrTanker:
                percentage = 0.08;
                break;

            case CoverType.GeneralCartage:
                percentage = 0.06;
                break;

            case CoverType.SpecialOnSite:
                percentage = 0.015;
                break;

            case CoverType.SpecialOnRoad:
                percentage = 0.03;
                break;

            case CoverType.GW1Class1:
                percentage = 0.05;
                break;

            case CoverType.GW1Class2:
                percentage = 0.06;
                break;

            case CoverType.GW1Class3:
                percentage = 0.07;
                break;

            default:
                break;
            }
            result = percentage * _value;
            return(await Task.FromResult(result));
        }
Exemplo n.º 21
0
 public void Add(object thumbnail, string name, object fullSizeImageCallback, CoverType coverType)
 {
     Add(thumbnail, name, String.Empty, -1, -1, fullSizeImageCallback, coverType);
 }
Exemplo n.º 22
0
 public void Add(object thumbnail, string name, string infoUri, int fullSizeImageWidth, int fullSizeImageHeight, object fullSizeImageCallback, CoverType coverType, string suggestedFilenameExtension)
 {
     //InfoUri and suggestedFilenameExtension are ignored.
     mResults.Add(new ScriptResult(mScript, thumbnail, name, fullSizeImageWidth, fullSizeImageHeight, fullSizeImageCallback, coverType));
 }
Exemplo n.º 23
0
 public void Add(object thumbnail, string name, string infoUri, int fullSizeImageWidth, int fullSizeImageHeight, object fullSizeImageCallback, CoverType coverType)
 {
     Add(thumbnail, name, infoUri, fullSizeImageWidth, fullSizeImageHeight, fullSizeImageCallback, coverType, null);
 }
Exemplo n.º 24
0
        public Task OfficeCharge()
        {
            var covertype = new CoverType();
            var value     = 0;

            switch (covertype)
            {
            case CoverType.PrivateIndividual:
                value = 55;
                break;

            case CoverType.Corporate:
                value = 55;
                break;

            case CoverType.Taxi:
                value = 60;
                break;

            case CoverType.Hiring:
                value = 60;
                break;

            case CoverType.MiniBus:
                value = 60;
                break;

            case CoverType.MaxiBus:
                value = 60;
                break;

            case CoverType.MotorCycle:
                value = 50;
                break;

            case CoverType.Ambulance:
                value = 57;
                break;

            case CoverType.OwnGoods:
                value = 65;
                break;

            case CoverType.ArticulatorOrTanker:
                value = 65;
                break;

            case CoverType.GeneralCartage:
                value = 65;
                break;

            case CoverType.SpecialOnSite:
                value = 40;
                break;

            case CoverType.SpecialOnRoad:
                value = 65;
                break;

            case CoverType.GW1Class1:
                value = 60;
                break;

            case CoverType.GW1Class2:
                value = 60;
                break;

            case CoverType.GW1Class3:
                value = 60;
                break;

            default:
                value = 0;
                break;
            }
            var result = value / 1;

            return(Task.FromResult(result));
        }
Exemplo n.º 25
0
 public BulkOrderBookCover(CoverType type)
     : this(type, 30)
 {
 }
Exemplo n.º 26
0
        public Task ThirdPartyBasicPremium()
        {
            double value;
            var    result    = results.THirdPartyBasicPre;
            var    covertype = new CoverType();

            switch (covertype)
            {
            case CoverType.PrivateIndividual:
                value = 272;
                break;

            case CoverType.Corporate:
                value = 272;
                break;

            case CoverType.Taxi:
                value = 378;
                break;

            case CoverType.Hiring:
                value = 387;
                break;

            case CoverType.MiniBus:
                value = 387;
                break;

            case CoverType.MaxiBus:
                value = 387;
                break;

            case CoverType.MotorCycle:
                value = 99;
                break;

            case CoverType.Ambulance:
                value = 297;
                break;

            case CoverType.OwnGoods:
                value = 387;
                break;

            case CoverType.ArticulatorOrTanker:
                value = 594;
                break;

            case CoverType.GeneralCartage:
                value = 486;
                break;

            case CoverType.SpecialOnSite:
                value = 198;
                break;

            case CoverType.SpecialOnRoad:
                value = 387;
                break;

            case CoverType.GW1Class1:
                value = 330;
                break;

            case CoverType.GW1Class2:
                value = 440;
                break;

            case CoverType.GW1Class3:
                value = 550;
                break;

            default:
                value = 0;
                break;
            }
            result = ((value) / (1));
            return(Task.FromResult(result));
        }
Exemplo n.º 27
0
 public void Add(CoverType cover)
 {
     _db.Add(cover);
 }
Exemplo n.º 28
0
 public CoverItemInfo(CoverType coverType)
 {
     this.cov_name = coverType.ToString();
 }
Exemplo n.º 29
0
			public void Add(object thumbnail, string name, string infoUri, int fullSizeImageWidth, int fullSizeImageHeight, object fullSizeImageCallback, CoverType coverType, string suggestedFilenameExtension)
			{
				if (!mSource.QueryContinueSearchInternal())
				{
					//Break out of this search
					mSource.AbortSearch();
					return;
				}

				if (mSource.FullSizeOnly || fullSizeImageCallback == null)
				{
					byte[] fullSizeData = null;
					if (fullSizeImageCallback != null) //If fullSizeImageCallback == null, then no full size image supplied, so the thumbnail is the full size image
					{
						//Try to get the full size image without getting the thumbnail
                        fullSizeData = mSource.RetrieveFullSizeImageData(fullSizeImageCallback);
					}
                    if (fullSizeData == null)
					{
						//Fall back on using the thumbnail as the full size
                        fullSizeData = BitmapHelpers.GetBitmapData(thumbnail);
					}
					if (fullSizeData != null)
					{
						mDispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate
						{
							mSource.Results.Add(new AlbumArt(mSource,
								name,
								infoUri,
                                fullSizeImageWidth,
                                fullSizeImageHeight,
								fullSizeData,
								coverType));
						}));
					}
				}
				else
				{
					byte[] thumbnailBitmapData = BitmapHelpers.GetBitmapData(thumbnail);

                    if (thumbnailBitmapData != null)
					{
						mDispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate
						{
							mSource.Results.Add(new AlbumArt(mSource,
                                thumbnailBitmapData,
								name,
								infoUri,
								fullSizeImageWidth,
								fullSizeImageHeight,
								fullSizeImageCallback,
								coverType,
								suggestedFilenameExtension));
						}));
					}
				}

				if (!mSource.QueryContinueSearchInternal())
				{
					//Break out of this search
					mSource.AbortSearch();
					return;
				}
			}
Exemplo n.º 30
0
        public void Remove(int id)
        {
            CoverType coverToDelete = _db.Covers.Find(id);

            _db.Covers.Remove(coverToDelete);
        }