private void ConvertToType(UnitTypeViewModel typeVM, MType type)
 {
     type.TypeName   = typeVM.TypeName;
     type.TypeStatus = typeVM.TypeStatus;
     type.TypeDesc   = typeVM.TypeDesc;
     type.MerkId     = string.IsNullOrEmpty(typeVM.MerkId) ? null : _merkTasks.One(typeVM.MerkId);
 }
        private void ConvertToWO(WOViewModel WOVM, TWO wo, FormCollection formCol)
        {
            //get customer id from form collection, customerVM not catch the customer id :(
            string custId = formCol["HiddenCustomerId"];
            string typeId = string.IsNullOrEmpty(formCol["TypeId.TypeID"]) ? formCol["TypeId"] : formCol["TypeId.TypeID"];
            string merkId = string.IsNullOrEmpty(formCol["MerkId.MerkID"]) ? formCol["MerkId"] : formCol["MerkId.MerkID"];

            //wo.WONo = WOVM.WONo;
            wo.CustomerId        = GetCustomer(custId);
            wo.WODate            = WOVM.WODate;
            wo.WOUnitName        = WOVM.WOUnitName;
            wo.WOUnitSn          = WOVM.WOUnitSn;
            wo.WOUnitIsGuarantee = WOVM.WOUnitIsGuarantee;
            wo.WOEquipments      = WOVM.WOEquipments;
            wo.WOPriority        = WOVM.WOPriority;
            wo.WOStartDate       = WOVM.WOStartDate;
            wo.WOLastStatus      = WOVM.WOLastStatus;
            wo.WOEstFinishDate   = WOVM.WOEstFinishDate;
            wo.WOTotal           = WOVM.WOTotal;
            wo.WODp                 = WOVM.WODp;
            wo.WOInvoiceNo          = WOVM.WOInvoiceNo;
            wo.WOTakenDate          = WOVM.WOTakenDate;
            wo.WOBrokenDesc         = WOVM.WOBrokenDesc;
            wo.WODesc               = WOVM.WODesc;
            wo.WOComplain           = WOVM.WOComplain;
            wo.MerkId               = string.IsNullOrEmpty(merkId) ? null : _merkTasks.One(merkId);
            wo.TypeId               = string.IsNullOrEmpty(typeId) ? null : _typeTasks.One(typeId);
            wo.WOUnitImei           = WOVM.WOUnitImei;
            wo.WOUnitColor          = WOVM.WOUnitColor;
            wo.WODateSentToSC       = WOVM.WODateSentToSC;
            wo.WODateReceivedFromSC = WOVM.WODateReceivedFromSC;
            wo.WOServiceFee         = WOVM.WOServiceFee;
            wo.WOSPartTotal         = WOVM.WOSPartTotal;
            wo.WOReferenceNo        = WOVM.WOReferenceNo;
        }
 private void ConvertToSPart(SPartViewModel spartVM, MSPart spart)
 {
     spart.SPartName          = spartVM.SPartName;
     spart.SPartPurchasePrice = spartVM.SPartPurchasePrice;
     spart.SPartServicePrice1 = spartVM.SPartServicePrice1;
     spart.SPartDesc          = spartVM.SPartDesc;
     spart.MerkId             = string.IsNullOrEmpty(spartVM.MerkId) ? null : _merkTasks.One(spartVM.MerkId);
 }
        public ActionResult Merks_Update([DataSourceRequest] DataSourceRequest request, UnitMerkViewModel merkVM)
        {
            if (merkVM != null && ModelState.IsValid)
            {
                var merk = _merkTasks.One(merkVM.MerkID);
                if (merk != null)
                {
                    ConvertToMerk(merkVM, merk);

                    merk.ModifiedDate = DateTime.Now;
                    merk.ModifiedBy   = User.Identity.Name;
                    merk.DataStatus   = "Updated";

                    _merkTasks.Update(merk);
                }
            }

            return(Json(ModelState.ToDataSourceResult()));
        }