/// <summary> /// Check for duplicate Item /// </summary> /// <param name="itemMl"></param> /// <returns></returns> static int CheckForDuplicate(ItemModel itemMl) { StringBuilder objStringBuilderError = new StringBuilder(); int duplicateItem = 0; //Cannot remove initialization of variable to zero.giving error "Use of unassigned local variable 'duplicateItem'" try { using (JetstreamClient objMainServiceClient = new JetstreamClient()) { if (objMainServiceClient.GetItemModelByEpc(itemMl) > 0) { duplicateItem = 1; } } } catch (FaultException<ServiceData> fex) { objStringBuilderError.AppendLine("In method : CheckForDuplicate(ItemModel itemMl) :: ItemController"); objStringBuilderError.AppendFormat("ErrorMessage::{0} {1}", fex.Detail.ErrorMessage, Environment.NewLine); objStringBuilderError.AppendFormat("ErrorDetails::{0} {1}", Environment.NewLine, fex.Detail.ErrorDetails); SaveLogger.SaveLoggerError(objStringBuilderError.ToString()); } catch (Exception ex) { objStringBuilderError.AppendLine("In method : CheckForDuplicate(ItemModel itemMl) :: ItemController"); objStringBuilderError.AppendFormat("ErrorMessage::{0} {1}", ex.Message, Environment.NewLine); objStringBuilderError.AppendFormat("ErrorDetails::{0} {1}", Environment.NewLine, ex.ToString()); SaveLogger.SaveLoggerError(objStringBuilderError.ToString()); } return duplicateItem; }